winsock newbie - effects of not closing sockets

winsock newbie - effects of not closing sockets

Post by David Le » Fri, 13 Jul 2001 22:01:24



Hello,

Does anyone know what the effects are of opening a socket, i.e. when
performing a ping, and never closing the socket.  My app does this every
minute.  Would the app just hang or would it crash or neither.
It is the same socket each time ... I am trying to implement a ping.  Here's
the code I use for the socket connection ( it's in C++ and  the parameters
are defined in winsock.h ):

            socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)

It doesn't return any error and I can see that I'm connecting alot of times
and I have since corrected this.  But I'm wondering if the crashes and hangs
I have been having in my app is because of this.  Would opening
hundreds of sockets cause the system to get bouged down ( take up
system resources ) or even crash the app??

Thanks

 
 
 

winsock newbie - effects of not closing sockets

Post by Jimb » Sat, 14 Jul 2001 07:45:54


hmm sounds like having too many file handles open  or Hwnds open ,neither
are very useful or benificial ,
I would be inclined to close the socket once I was done pinging thru it ..

Quote:> Hello,

> Does anyone know what the effects are of opening a socket, i.e. when
> performing a ping, and never closing the socket.  My app does this every
> minute.  Would the app just hang or would it crash or neither.
> It is the same socket each time ... I am trying to implement a ping.
Here's
> the code I use for the socket connection ( it's in C++ and  the parameters
> are defined in winsock.h ):

>             socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)

> It doesn't return any error and I can see that I'm connecting alot of
times
> and I have since corrected this.  But I'm wondering if the crashes and
hangs
> I have been having in my app is because of this.  Would opening
> hundreds of sockets cause the system to get bouged down ( take up
> system resources ) or even crash the app??

> Thanks


 
 
 

winsock newbie - effects of not closing sockets

Post by David Le » Sat, 14 Jul 2001 21:34:28


Hi,

Thanks for replying.  I do close the socket now.  But Im trying to build a
stable app and I
was wondering if past crashes and hangs could be caused by not closing
sockets properly.
What do you think?


> hmm sounds like having too many file handles open  or Hwnds open ,neither
> are very useful or benificial ,
> I would be inclined to close the socket once I was done pinging thru it ..


> > Hello,

> > Does anyone know what the effects are of opening a socket, i.e. when
> > performing a ping, and never closing the socket.  My app does this every
> > minute.  Would the app just hang or would it crash or neither.
> > It is the same socket each time ... I am trying to implement a ping.
> Here's
> > the code I use for the socket connection ( it's in C++ and  the
parameters
> > are defined in winsock.h ):

> >             socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)

> > It doesn't return any error and I can see that I'm connecting alot of
> times
> > and I have since corrected this.  But I'm wondering if the crashes and
> hangs
> > I have been having in my app is because of this.  Would opening
> > hundreds of sockets cause the system to get bouged down ( take up
> > system resources ) or even crash the app??

> > Thanks