Information Technology Reference
In-Depth Information
shutdown()
The shutdown() function disables send or receive operations on a socket and does not close
any opened sockets. Its syntax is
int shutdown(SOCKET s, int how)
where
Socket descriptor.
s
how
Flag that identifies operation types that will no longer be allowed. These are:
0 - Disallows subsequent receives.
1 - Disallows subsequent sends.
2 - Disables send and receive.
If no error occurs then it returns a zero value. Otherwise, it returns INVALID_SOCKET , and the
specific error code can be tested with WSAGetLastError .
closesocket()
The closesocket() function closes a socket. Its syntax is:
int closesocket (SOCKET s);
where
s
Socket descriptor.
If no error occurs then it returns a zero value. Otherwise, it returns INVALID_SOCKET , and the
specific error code can be tested with WSAGetLastError .
24.10 Visual Basic socket implementation
Visual Basic supports a WinSock control and allows the connection of hosts over a network.
It supports both UDP and TCP. Figure 24.11 shows a sample Visual Basic screen with a
WinSock object (in this case, it is named Winsock1). To set the protocol used then either
select the properties window on the WinSock object, click protocol and select sckTCPProto-
col, or sckUDPProtocol. Otherwise, within the code it can be set to TCP with:
Winsock1.Protocol = sckTCPProtocol
The WinSock object has various properties, such as:
obj . RemoteHost
Defines the IP address or domain name of the remote host.
obj . LocalPort
Defines the local port number.
The methods that are used with the WinSock object are:
Search WWH ::




Custom Search