Home > Software engineering >  Why WINSOCK control server-side WINSOCK control carried out after the close event, the client of the
Why WINSOCK control server-side WINSOCK control carried out after the close event, the client of the

Time:09-26

Why WINSOCK control server-side WINSOCK control carried out after the close event, the client of the WINSOCK control tcpClient_Close constantly repeated execution,

The code is as follows:

Private Sub tcpServer_DataArrival (Index As an Integer, ByVal bytesTotal As Long) 'server receives a client sending a Q characters, the server to establish connections with the client of the WINSOCK control execution CLOSE operation,
Dim sData As String
Dim sName As String

TcpServer (Index). GetData sData
RtbSave. SelStart=Len (rtbSave. Text)

SName=Left (sData, 1)

If the sName="Q" Then
tcpServer (Index). Close 'with this client connect WINSOCK control execution Close operation
End the If

End Sub

Private Sub tcpClient_Close () 'execution on the server tcpServer (Index). After the Close of the client automatically produce tcpClient_Close events, and executed repeatedly

End Sub


Server side implementation tcpServer (Index). After the Close of the client automatically generated tcpClient_Close events, and perform repeatedly, normal should be performed once, just finished, why the repeated continuously perform it?

Thank you for your attention

CodePudding user response:

Best for all of the code, as such things look not to come out...

CodePudding user response:

 Private Sub tcpClient_Close () 
TcpClient Close 'to add this sentence try again
'...
End Sub

CodePudding user response:

refer to the second floor zhao4zhong1 response:
 Private Sub tcpClient_Close () 
TcpClient Close 'to add this sentence try again
'...
End Sub


Add this sentence, can, if the client tcpClient after receiving the CLOSE events to the server, not their execution tcpClient. The CLOSE operation, only by application developer to perform in the event of client tcpClient_Close tcpClient. CLOSE to shut down,
And ask is tcpClient. Close this operation, what is turned off, is (1) connected to the server the WINSOCK (2) the other?

Thank you very much,

CodePudding user response:


The Close event


When the remote computer closes the connection, application should correctly use the Close method closing the TCP connection ,

Syntax

Object_Close ()

Object where represents an object expression, and its value is "applied" in the list of objects,

Parameter

None



The Close method (Winsock control)


Closed a TCP connection to the client and server applications or a listening socket,

Syntax

Object. The Close

Object of the representative object expression, and its value is "applied" in the list of objects,

Parameter

None

The return value

Void

CodePudding user response:

reference 4 floor zhao4zhong1 response:

The Close event
When the remote computer closes the connection, application should correctly use the Close method closing the TCP connection,


Thank you very much, said data in
when the remote computer closes the connection, the application should correct the Close method is used to Close the TCP connection,

The remote computer does not have closed the TCP connection, dry client or shut down? Is there, you haven't answered, why the client tcpClient_Close event triggered repeatedly?

CodePudding user response:

Why the client tcpClient_Close event triggered repeatedly?
Will you be in VB6 ides tcpClient_Close event the breakpoint is set on a line of code, and then every time the breakpoint fires, press Ctrl + L (or click the view, the call stack), the call stack in the pop-up dialog to view from the top to the following out of from the inner to the outer function call history?

CodePudding user response:

refer to 6th floor zhao4zhong1 response:
why client tcpClient_Close events triggered again and again?
Will you be in VB6 ides tcpClient_Close event the breakpoint is set on a line of code, and then every time the breakpoint fires, press Ctrl + L (or click the view, the call stack), the call stack in the pop-up dialog to view from the top to the following out of from the inner to the outer function call history?


Thank you very much, zhao four teachers,

CodePudding user response:

refer to 6th floor zhao4zhong1 response:
why client tcpClient_Close events triggered again and again?
Will you be in VB6 ides tcpClient_Close event the breakpoint is set on a line of code, and then every time the breakpoint fires, press Ctrl + L (or click the view, the call stack), the call stack in the pop-up dialog to view from the top to the following out of from the inner to the outer function call history?


Press CTRL + L, after the prompt, as shown in the figure below:



That call themselves?

CodePudding user response:

This isn't the call themselves?

CodePudding user response:

You may have to write like this:
 Private Sub tcpClient_Close () 

If tcpClient. State<> SckClosed Then tcpClient. Close 'to try it again

'...

End Sub

CodePudding user response:

The
references to the tenth floor zhao4zhong1 response:
you may have to write like this:
 Private Sub tcpClient_Close () 

If tcpClient. State<> SckClosed Then tcpClient. Close 'to try it again

'...

End Sub


Thank you very much and tried, ok, but want to question, why not perform tcpClient. Close, Private Sub tcpClient_Close () will be continuously executed automatically?

CodePudding user response:

reentrant
Recursive
  • Related