Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WINSOCK LOST CONNECTION BLUES

Status
Not open for further replies.

TrueCode

MIS
Joined
Sep 30, 2003
Messages
71
Location
LC
I have been able to deal with the problem of server hanging up when client form is released. Now, I want to know when my client has left the connection. I have set a timer to show the connection state at various points. But even after the client has disconnected, the timer still returns a state of 7 (connected)

Please help.

------------------------------------->

"I have sought your assistance on this matter because I have exhausted all the help that I can find. You are free to direct me to other source of help"
 
TrueCode,

Do you have a THIS.Close() in the Close event of your winsock control?

Andy
 
yes...I do.


------------------------------------->

"I have sought your assistance on this matter because I have exhausted all the help that I can find. You are free to direct me to other source of help"
 
TrueCode,

What code are you running on the client end to close the connection?

Andy
 
Agoeddeke

I was offline for a while.

I simple have this.object.close in the close method.

My problem occurs when the network cable is pulled out or one of the party just powers off.

The other party still advertises a connected state.


------------------------------------->

"I have sought your assistance on this matter because I have exhausted all the help that I can find. You are free to direct me to other source of help"
 
TrueCode,

I have always used a THIS.Close() in the close event rather than a THIS.Object.Close(). Not sure if it makes a difference.

If the server is hanging or acting sluggish I would put some code in the Error event of the winsock control to see what's going on. I had similar trouble when a client disconnected and the error event on the server would fire continuously without closing the socket. I had to put some code in to trap for the error and call THIS.Close() directly in the error event.

Here is error event code from my base socket class. You can maybe pull some ideas from it:


*** ActiveX Control Event ***
LPARAMETERS znumber, zdescription, zscode, zsource, zhelpfile, zhelpcontext, zcanceldisplay

lcError = LTRIM(STR(znumber))

IF lcError != "109" AND lcError != "232"
** 109 = The Pipe has been ended.
** 232 = The Pipe is being closed.
** These are not truly errors so we ignore them
THIS.r_cSocketError = lcError
STRTOFILE(TTOC(DATETIME()) + " " + lcError + CHR(13) + CHR(10), "c:\sockerr.txt", 1)
IF THIS.State = 7 OR THIS.State = 9
IF ! THIS.r_lClosedSocket
THIS.CLOSE()
RETURN
ELSE
NODEFAULT
ENDIF
ENDIF
NODEFAULT
ENDIF
RETURN

Good luck,
Andy
 
thanks Andy, I will try it this evening. Look out for a reply tomorrow.


------------------------------------->

"I have sought your assistance on this matter because I have exhausted all the help that I can find. You are free to direct me to other source of help"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top