comp.lang.ada
 help / color / mirror / Atom feed
* Socket buffer filling up
@ 1999-11-18  0:00 Josh Highley
  1999-11-18  0:00 ` Josh Highley
  0 siblings, 1 reply; 6+ messages in thread
From: Josh Highley @ 1999-11-18  0:00 UTC (permalink / raw)


  I'm using Jerry van Dijk's AdaSockets package.  My program performs a 
loop in which two different connections are opened, then closed.  There is 
then a programmed delay of several minutes before the loop is repeated.  My 
problem is that after running for several hours, the socket buffer fills up 
and I get errors when trying to connect, and my web browser can't reach any 
websites.  When I terminate my program, my browser then works fine.

Here's the main points of my code:

WITH Sockets;
USE  Sockets;
-- other withs and uses

PROCEDURE my_sockets IS 

   Connection1 : Socket_Fd;
   Connection2 : Socket_Fd;
   Http_Port   : CONSTANT Positive  := 80;  
   Web_Server1 : CONSTANT String    := "www.server-one.com";
   Web_Server2 : CONSTANT String    := "www.server-two.com";  

BEGIN  -- main program
      Connection1 := Socket (Af_Inet, Sock_Stream);
      Put_Line("Connecting. . .");
      Connect (Connection1, Web_Server1, Http_Port);
    	-- put stuff on socket
      -- get stuff from socket
      Shutdown(Connection1);

    	-- parse the data received

      Connection2 := Socket (Af_Inet, Sock_Stream);
      Connect(Connection2, Web_Server2, Http_Port);

      -- put stuff on socket
      -- get stuff from socket until certain information is found, then...
      Put_Line("Closing Connection.");
      Shutdown(Connection2);
      DELAY Seconds_Wait;  -- I've been delaying 3 minutes
   END LOOP;

END my_sockets;


Looking through the sockets package, I noticed "Bind" and "Setsockopt" 
which has a SO_REUSEADDR option.  I've looked at numerous sources on the 
web, trying to find the exact purpose and use of these but couldn't find 
any answers.

Now that I'm looking at my abbreviated code, I realize that I'm not getting 
all of the data sent to me on Connection2.  This is on purpose since I only 
need a little piece of information (the number of new messages in my email 
account)  I then close the connection without getting the rest of the data.  
I've been assuming that I get the data as the server sends it, but I guess 
the data is stored in the buffer and I 'get' the data from the buffer, 
which is why the buffer is filling up.  Is this correct; did I just answer 
my own question?  I think I got confused on what was going in the buffer.  
Anyway, I'm still interested in getting more info on the other functions in 
Sockets, like Bind and Setsockopt, if anyone knows some sources.

Thanks,

Josh Highley
joshhighley@hotmail.com




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Socket buffer filling up
  1999-11-18  0:00 Socket buffer filling up Josh Highley
@ 1999-11-18  0:00 ` Josh Highley
  1999-11-18  0:00   ` Chad R. Meiners
  1999-11-18  0:00   ` David C. Hoos, Sr.
  0 siblings, 2 replies; 6+ messages in thread
From: Josh Highley @ 1999-11-18  0:00 UTC (permalink / raw)


joshhighley@hotmail.com (Josh Highley) wrote in 
<383403bd.0@silver.truman.edu>:

oops, my code wasn't correct, I forgot to specify the beginning of the 
loop.  Here's the correct code, hopefully:

WITH Sockets;
USE  Sockets;
-- other wits and uses

PROCEDURE my_sockets IS 

   Connection1 : Socket_Fd;
   Connection2 : Socket_Fd;
   Http_Port   : CONSTANT Positive  := 80;  
   Web_Server1 : CONSTANT String    := "www.server-one.com";
   Web_Server2 : CONSTANT String    := "www.server-two.com";  

BEGIN  -- main program
   LOOP 
      Connection1 := Socket (Af_Inet, Sock_Stream);
      Put_Line("Connecting. . .");
      Connect (Connection1, Web_Server1, Http_Port);
         -- put stuff on socket
      -- get stuff from socket
      Shutdown(Connection1);

         -- parse the data received

      Connection2 := Socket (Af_Inet, Sock_Stream);
      Connect(Connection2, Web_Server2, Http_Port);

      -- put stuff on socket
      -- get stuff from socket until certain information is found, then...
      Put_Line("Closing Connection.");
      Shutdown(Connection2);
      DELAY Seconds_Wait;  -- I've been delaying 3 minutes
   END LOOP;

END my_sockets;


Thanks,

Josh Highley
joshhighley@hotmail.com






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Socket buffer filling up
  1999-11-18  0:00 ` Josh Highley
@ 1999-11-18  0:00   ` Chad R. Meiners
  1999-11-19  0:00     ` Laurent Guerby
  1999-11-18  0:00   ` David C. Hoos, Sr.
  1 sibling, 1 reply; 6+ messages in thread
From: Chad R. Meiners @ 1999-11-18  0:00 UTC (permalink / raw)


Josh,

    I believe your problem has to do with the fact you are only shutting
down the socket and not closing it.  You are running out of available
sockets so either you need to reuse the sockets you have, or you need to use
the close_socket api form the Winsock api's to release them so other
programs can allocate sockets.  I have extended Jerry's socket package to
have this functionality.   E-mail me if you would like this package

-Chad R. Meiners

Josh Highley <joshhighley@hotmail.com> wrote in message
news:383404ee.0@silver.truman.edu...
> joshhighley@hotmail.com (Josh Highley) wrote in
> <383403bd.0@silver.truman.edu>:
>
> oops, my code wasn't correct, I forgot to specify the beginning of the
> loop.  Here's the correct code, hopefully:
>
> WITH Sockets;
> USE  Sockets;
> -- other wits and uses
>
> PROCEDURE my_sockets IS
>
>    Connection1 : Socket_Fd;
>    Connection2 : Socket_Fd;
>    Http_Port   : CONSTANT Positive  := 80;
>    Web_Server1 : CONSTANT String    := "www.server-one.com";
>    Web_Server2 : CONSTANT String    := "www.server-two.com";
>
> BEGIN  -- main program
>    LOOP
>       Connection1 := Socket (Af_Inet, Sock_Stream);
>       Put_Line("Connecting. . .");
>       Connect (Connection1, Web_Server1, Http_Port);
>          -- put stuff on socket
>       -- get stuff from socket
>       Shutdown(Connection1);
>
>          -- parse the data received
>
>       Connection2 := Socket (Af_Inet, Sock_Stream);
>       Connect(Connection2, Web_Server2, Http_Port);
>
>       -- put stuff on socket
>       -- get stuff from socket until certain information is found, then...
>       Put_Line("Closing Connection.");
>       Shutdown(Connection2);
>       DELAY Seconds_Wait;  -- I've been delaying 3 minutes
>    END LOOP;
>
> END my_sockets;
>
>
> Thanks,
>
> Josh Highley
> joshhighley@hotmail.com
>
>






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Socket buffer filling up
  1999-11-18  0:00 ` Josh Highley
  1999-11-18  0:00   ` Chad R. Meiners
@ 1999-11-18  0:00   ` David C. Hoos, Sr.
  1 sibling, 0 replies; 6+ messages in thread
From: David C. Hoos, Sr. @ 1999-11-18  0:00 UTC (permalink / raw)



Josh Highley <joshhighley@hotmail.com> wrote in message
news:383404ee.0@silver.truman.edu...
> joshhighley@hotmail.com (Josh Highley) wrote in
> <383403bd.0@silver.truman.edu>:
>
The best source of information about things like socket options (e.g.
SO_REUSEADDR),
is UNIX Network Programming by W. Richard Stevens.

First Edition (1990) - ISBN 0-13-949876-1
Second Edition (1998 -- two volumes)
    Sockets covered in Volume 1 ISBN 0-13-490012-X
    Interprocess Communication covered in Volume 2 ISBN 0-13-081081-9-X








^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Socket buffer filling up
  1999-11-19  0:00     ` Laurent Guerby
@ 1999-11-19  0:00       ` tmoran
  0 siblings, 0 replies; 6+ messages in thread
From: tmoran @ 1999-11-19  0:00 UTC (permalink / raw)


>possible to check that the peer on the socket is still here without
  How about "getpeername"?  Or if you are using a WSAAsync socket
you can of course get a message when the connection is dropped.
(With raw Winsock.  With CLAW you would likely call procedure
Get_Peer or overide the inherited procedure When_Disconnect.)




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Socket buffer filling up
  1999-11-18  0:00   ` Chad R. Meiners
@ 1999-11-19  0:00     ` Laurent Guerby
  1999-11-19  0:00       ` tmoran
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent Guerby @ 1999-11-19  0:00 UTC (permalink / raw)


"Chad R. Meiners" <v025@truman.edu> writes:
>     I believe your problem has to do with the fact you are only shutting
> down the socket and not closing it.  You are running out of available
> sockets so either you need to reuse the sockets you have, or you need to use
> the close_socket api form the Winsock api's to release them so other
> programs can allocate sockets.  I have extended Jerry's socket package to
> have this functionality.   E-mail me if you would like this package

I noticed the problem some time ago and notified the Unix and NT
maintainers, they both told me that it would be fixed in the next
release of adasocket.

On Unix, you need to call C_Close (which is in the thin binding),
and on NT as Chad mentionned.

BTW, while we have socket experts on line, I'd like to know if it is
possible to check that the peer on the socket is still here without
having to send data (and thus getting some kind of connection lost)?

Thanks for any insight,

--LG




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-11-19  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-18  0:00 Socket buffer filling up Josh Highley
1999-11-18  0:00 ` Josh Highley
1999-11-18  0:00   ` Chad R. Meiners
1999-11-19  0:00     ` Laurent Guerby
1999-11-19  0:00       ` tmoran
1999-11-18  0:00   ` David C. Hoos, Sr.

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