| | |
Simple Winsock Question?
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
Hello everyone. Im sure this is a simple winsock question but maybe im wrong...
I searched everywhere and keep hitting dead ends.
Im just learning how to use winsock and still have yet to find a good tutorial. But i found a class which i will start with. Only problem is...
When i try to recv(...); the program waits until it receives somthing. Is there a way to do like:
And if you know of a good winsock tutorial that starts from the very basics, doesent do like the windows ones and most of them and just gives u what you put. I wana actualy understand what im doing : /
Thanks!
BTW: i know this code would never work and/or come up w/ errors, its just a general idea of what i would like to do.
I searched everywhere and keep hitting dead ends.
Im just learning how to use winsock and still have yet to find a good tutorial. But i found a class which i will start with. Only problem is...
When i try to recv(...); the program waits until it receives somthing. Is there a way to do like:
C++ Syntax (Toggle Plain Text)
char msg[256]; bool quit = false; while(!quit) { if(recv(msg)) // as it goes through the loop, if it received somthing cout << "User: " << msg << endl; // display it if(GetKeyState(VK_RETURN)<0) // when you type enter { cout << "Message: "; // prompt for your message cin.getline(msg,256); // input your message send(msg); // send it } if(GetKeyState(VK_ESCAPE)<0) quit = true; }
And if you know of a good winsock tutorial that starts from the very basics, doesent do like the windows ones and most of them and just gives u what you put. I wana actualy understand what im doing : /
Thanks!
BTW: i know this code would never work and/or come up w/ errors, its just a general idea of what i would like to do.
Last edited by u8sand; Jan 10th, 2009 at 10:45 pm.
ioctl is a function to alter the way input/output is controlled/handled/works. http://msdn.microsoft.com/en-us/libr...50(VS.85).aspx is a helpful site about using ioctl with winsock. One of the constants that you pass to ioctl, in order to stop the socket from blocking (blocking means waits for input) is FIONBIO.
The alternative measure is a messy way to do things, and mostly was put there jokingly. While threads and function pointers can be a great asset (when designed very carefully), they usually lead to more trouble than they end up being worth.
The alternative measure is a messy way to do things, and mostly was put there jokingly. While threads and function pointers can be a great asset (when designed very carefully), they usually lead to more trouble than they end up being worth.
![]() |
Similar Threads
- simple question (C++)
- Can some please confirm winsock (Visual Basic 4 / 5 / 6)
- How would I find a system's IP address in Delphi? (Pascal and Delphi)
Other Threads in the C++ Forum
- Previous Thread: Input time as hh:mm and no other way
- Next Thread: Functions Calling Functions
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete desktop developer directshow dll dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






