× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



"Jim Langston" <jlangston@celsinc.com> wrote in message
4450A3C6B2D8F940821FB6B28A4D55FE230EC9@MAIL2.celsinc.com">news:4450A3C6B2D8F940821FB6B28A4D55FE230EC9@MAIL2.celsinc.com...
> How is it that you are closing socket 0 if you don't have a handle to it?

Apparently socket isn't really a handle ... it's *JUST* a number.  When my
program started, the int variable I use to hold the socket was initialized
to zero.  Before my program opened up a new connection, it tried to close
the current one (because it assumed the previous connection had been closed
by the other side).  Thus, my program would close socket 0.

Closing a socket that wasn't open doesn't generate an error.

My logic was this (roughtly)...

start program

socketvar = 0

loop:
    closesocket(socketvar)
    socketvar = opensocket()
    do stuff
    wait
    do stuff
    oops, got a send error, socket must have been closed by other side
    goto loop

I changed my code to be something more like this ...

socketvar = -1

loop:
    if (socket => 0)  // first time through, won't try to close the socket
        closesocket(socketvar)
    socketvar = opensocket()
    do stuff
    wait
    do stuff
    oops, got a send error, socket must have been closed by other side
    goto loop

This way, I only try to close the socket if I actually opened it.

david






As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.