User`s guide

Table Of Contents
Chapter 12 191
Sample Application Programs
Controlling Using Telnet Server
12. Sample Application
Programs
Disconnection
The procedure corresponding to Disconnection is CloseConnection (Example 12-12).
CloseConnection disconnects communication and removes a socket using closesocket
function of
WinSock API. closesocket function takes a parameter for a socket
descriptor (input).
Example 12-12 CloseConnection
Sub CloseConnection()
x = closesocket(socketId)
If x = SOCKET_ERROR Then
MsgBox ("ERROR: closesocket = " + Str$(x))
Exit Sub
End If
End Sub
End
The procedure corresponding to End is EndIt (Example 12-13). EndIt disconnects
WinSock API using WSACleanup function of WinSock API. The function
WSACleanup should be always used when terminating WinSock.
Example 12-13 EndIt
Sub EndIt()
'Shutdown Winsock DLL
x = WSACleanup()
End Sub