![]() |
| | #1 |
| Registered User Join Date: Dec 2008
Posts: 183
| how to intilise a non blocking socket? |
| lolguy is offline | |
| | #2 |
| Registered User Join Date: Apr 2008
Posts: 309
| You can use fcntl() to change a socket to be blocking or nonblocking. Code: result = fcntl(sck, F_GETFL, NULL); //This sets the socket to nonblocking result |= O_NONBLOCK; Code: result = fcntl(sck, F_GETFL, NULL); //This sets the socket to blocking result &= (~O_NONBLOCK); Edit: This is after you have actually created the socket (sck = socket()) |
| carrotcake1029 is offline | |
| | #3 |
| Registered User Join Date: Dec 2008
Posts: 183
| yes but i think that function is linux right ?not win? |
| lolguy is offline | |
| | #4 |
| Registered User Join Date: Apr 2008
Posts: 309
| So sorry, just making blind assumptions. I think the equivalent would be basically the same thing but using ioctlsocket() with a FIONBIO flag. msdn: Code: //------------------------- // Set the socket I/O mode: In this case FIONBIO // enables or disables the blocking mode for the // socket based on the numerical value of iMode. // If iMode = 0, blocking is enabled; // If iMode != 0, non-blocking mode is enabled. u_long iMode = 0; ioctlsocket(m_socket, FIONBIO, &iMode); |
| carrotcake1029 is offline | |
| | #5 |
| Resu Deretsiger Join Date: Nov 2008 Location: /dev/null
Posts: 185
| Note that winsock is almost a direct clone of the BSD sockets library, which is what Linux uses . . .
__________________ Do as I say, not as I do . . . Experimentation is the essence of programming. Just remember to make a backup first. "I'm a firm believer that <SomeGod> gave us two ears and one mouth for a reason - we are supposed to listen, twice as much as we talk." - LEAF Questions posted by these guidelines are more likely to be answered. Debian GNU/Linux user, with the awesome window manager, the git version control system, and the cmake buildsystem generator. |
| Nightowl is offline | |
| | #6 | |
| Registered User Join Date: Dec 2008
Posts: 183
| Quote:
| |
| lolguy is offline | |
| | #7 |
| Registered User Join Date: Dec 2008
Posts: 183
| anyways let me post my problem code in other thread . thanks for the help guys. |
| lolguy is offline | |
| | #8 |
| Registered User Join Date: Dec 2008
Posts: 183
| oh i forgot WSAstartup stupid me |
| lolguy is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Nonblocking socket...blocking? | zolom | Networking/Device Communication | 2 | 07-13-2009 12:06 PM |
| EAGAIN with write on a non blocking socket | mynickmynick | Networking/Device Communication | 0 | 04-30-2009 09:59 AM |
| How to initialize a non blocking socket using only winsock library | *DEAD* | Networking/Device Communication | 4 | 01-18-2008 07:03 AM |
| socket blocking problem | killerbyte | Linux Programming | 2 | 05-21-2006 03:25 PM |
| Socket Blocking Trouble! | LearningMan | Windows Programming | 6 | 01-09-2003 10:09 AM |