Author | Topic: Handles increasing while socketopen | |
---|---|---|
Bernd Reinhardt | Handles increasing while socketopen on Thu, 26 Apr 2007 10:50:32 +0200 Hi all. I try to connect to a socketserver, but the server is not always available. do while .t. nError := 0 nSocket := SocketOpen(SOCK_STREAM, cQuartzIp, nQuartzPort, @nError) if nSocket > 0 .and. nError == 0 exit socketserver is availalble else socket server is not available SocketShutdown( nSocket, SD_BOTH , @nError) I tried this, but increasing handles still happens. socketclose(nSocket) nSocket := NIL endif enddo If I watch to the taskmanger handles increase untill the program hangs. Is there a posibility to check if socket is available without always new handle. Any Idea? Regards Bernd | |
Phil Ide | Re: Handles increasing while socketopen on Thu, 26 Apr 2007 17:05:01 +0100 Bernd, > Hi all. > I try to connect to a socketserver, but the server is not always available. > > do while .t. > nError := 0 > nSocket := SocketOpen(SOCK_STREAM, cQuartzIp, nQuartzPort, @nError) > if nSocket > 0 .and. nError == 0 > exit > socketserver is availalble > else socket server is not available > SocketShutdown( nSocket, SD_BOTH , @nError) I tried this, but > increasing handles still happens. > socketclose(nSocket) > nSocket := NIL > endif > enddo > > If I watch to the taskmanger handles increase untill the program hangs. > Is there a posibility to check if socket is available without always new > handle. Unfortunately not, because any other method will rely on features of the remote server that are not required by the application providing the socket - for example, doing a PING can be useful, but only if the remote server supports the PING protocol. In the event that you do not make a connection on the socket, DO NOT perform a SocketShutDown() on the local socket. In theory, this waits until all pending send/recv operations complete on the socket before closing it, which should mean an immediate close, but since you already know that there is no data pending on the socket an explicit SocketClose() is more appropriate. Regards, Phil Ide --------------------- www.xbhcl.com www.pbih.eu www.idep.org.uk/xbase --------------------- A fool and his money soon become a sysop! |