Programming
1295
RecvAscii = RECV_ERROR '............(1)
dataBuf = Chr$(0) '
Exit Function '
End If '
If c = Chr$(10) Then '
dataBuf = dataBuf + Chr$(0) '............(2)
RecvAscii = NO_ERROR '
Exit Function '
End If '
length = length + count '............(3)
dataBuf = dataBuf + c '
Wend
RecvAscii = RECV_ERROR
End Function
Disconnection
The procedure corresponding to Disconnection is CloseConnection.
CloseConnection disconnects communication and removes a socket using
the closesocket function of WinSock API. The closesocket function takes a
socket descriptor (input) as its parameter.
c
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. EndIt disconnects WinSock
API using the WSACleanup function of WinSock API. The function
WSACleanup should always be used when terminating WinSock.
EndIt
Sub EndIt()