| | |
How to make a non-blocking socket?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Yes, thank you CSurfer.
The very quick brief is first you calculate how many processors are in your computer then multiply by two and launch that many threads. You'll have to do a bit more to micro-manage them for the processor distribution if you want more balance. They get put to sleep waiting for an event generated by the I/O completion port. The I/O completion port also waits for events generated by your sockets. (IOCP's can be used for other event types too!) An I/O event occurs, a thread is wakened and a user value is handed to the thread as to what event object caused an event. So the thread wakes up, checks the status of the socket, and deals with it accordingly then goes back to sleep.
That's the short brief but its a very cool mechanism. I have used it for running thousands of sockets on quad and sixteen core systems.
The very quick brief is first you calculate how many processors are in your computer then multiply by two and launch that many threads. You'll have to do a bit more to micro-manage them for the processor distribution if you want more balance. They get put to sleep waiting for an event generated by the I/O completion port. The I/O completion port also waits for events generated by your sockets. (IOCP's can be used for other event types too!) An I/O event occurs, a thread is wakened and a user value is handed to the thread as to what event object caused an event. So the thread wakes up, checks the status of the socket, and deals with it accordingly then goes back to sleep.
That's the short brief but its a very cool mechanism. I have used it for running thousands of sockets on quad and sixteen core systems.
•
•
•
•
If you could just tell me how to set a socket to non blocking and explain select() to me I'd be grateful.
![]() |
Similar Threads
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- Netgear router blocking Hotmail (again) (Networking Hardware Configuration)
- Recv()ing a long message (C++)
- Make a non-blocking windows Socket? (C++)
- Please make my frist socket app work... (C++)
- My yahoo client. Not receiving data in real time :(( Just need a bit of advice (Perl)
Other Threads in the C++ Forum
- Previous Thread: Intro and question
- Next Thread: Need some help understanding MFC
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






