comp.lang.ada
 help / color / mirror / Atom feed
* Blocking and non-blocking sockets
@ 2002-10-14 21:50 Rob Mitchelmore
  0 siblings, 0 replies; only message in thread
From: Rob Mitchelmore @ 2002-10-14 21:50 UTC (permalink / raw)


Hi:

I'm not sure if this is a newbie question, but I'm having a problem
with GNAT.Sockets (using GNAT for Win32 under XP).  I'm aiming to
create a listening socket which does a non-blocking Socket_Accept.

When I create a blocking socket, Socket_Accept works as expected,
blocking until a connection is received on the port, at which point
execution continues, and I can use Stream(Client_Sock) and so forth.

However, when I use Control_Socket to enable non-blocking mode for the
socket, Socket_Accept still seems to block (or at least execution
never continues past that call), accepting a connection and then
leaving it 'hanging', never progressing past that point.

Is there something I am doing gratuitously wrong here?

Thanks very much,

Rob

-- snippet
   procedure Create_Server_Socket(Port : in Port_Type;
         Socket : out Socket_Type) is
      Address : Sock_Addr_Type;
      Nonblock   : Request_Type(Non_Blocking_IO);
   begin
      Address.Addr := Inet_Addr("127.0.0.1");
      Address.Port := Port;
      Create_Socket(Socket);
      Bind_Socket(Socket, Address);
      Listen_Socket(Socket);
      -- If I uncomment the following line, the problem appears:
      -- Nonblock.Enabled := true;
      Control_Socket(Socket, Nonblock);
   end Create_Server_Socket;
-- end snippet



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-14 21:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-14 21:50 Blocking and non-blocking sockets Rob Mitchelmore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox