Home » U++ Library support » U++ Callbacks and Timers » Problem with non-blocking mode
Problem with non-blocking mode [message #23493] |
Fri, 23 October 2009 11:02  |
Weras
Messages: 4 Registered: August 2009
|
Junior Member |
|
|
Hi!
I have a problem with sockets, namely, a non-blocking mode. I must say that until that moment I had never worked with sockets and my
question may seem silly.
In my project, I repeated the tutorial from the Help Topics "Connection-Oriented Socket Tutorial"
Function accept_socket.Accept (data_socket, & ip_addr)
suspends the entire program, so I point out that the socket nonblocking:
Socket::Init();
if( !ServerSocket(accept_socket, portInfo.portNumber) )
throw Exc("Couldn't bind socket on the local port.");
if( accept_socket.IsOpen() )
{
dword ip_addr;
accept_socket.Block(false);
accept_socket.Peek();
if( !accept_socket.IsError() && accept_socket.Accept(data_socket, &ip_addr) )
{
Cout() << "Connection from " << FormatIP(ip_addr) << "\n";
while(data_socket.IsOpen() && !data_socket.IsEof() && !data_socket.IsError())
Cout() << data_socket.Read();
}
}
But the program still awaits all perform the function Accept. What I missed or am doing wrong?
Also I read that non-blocking socket's have callback when connection started(or something like that). Could you give examples code using this opportunity socket?
P.S.
Sorry my english )
[Updated on: Fri, 23 October 2009 14:55] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Tue Jul 08 08:11:59 CEST 2025
Total time taken to generate the page: 0.03753 seconds
|