standard.net.socket.SocketClose

SocketClose is available since version 1.0.

Prototype:

number SocketClose(number socket)

Parameters

socket
a valid and socket descriptor, as returned by SocketCreate

Description:

Closes a socket. After a socket is closed, it cannot be used.

Return value:

Returns 0 if succeeded, or -1 if failed. This function fails is socket is not a socket descriptor, the network subsystem fails, a blocking socket call is in progress, or the service provider is still processing a callback function or the socket is marked as nonblocking and SO_LINGER is set to a nonzero time-out value.

Example
import standard.net.socket

class Main {
	function Main() {
		var s=SocketCreate();

		echo "Connecting ... ";
		if (SocketConnect(s,"localhost",3500)==-1) {
			echo "Couldn't Connect :"+SocketError(s)+"\n";
			return 0;
		}

		echo "Connected !\n";

		for (var i=0;i<10;i++)
			echo SocketWrite(s,"SUPERMAN $i !");
		SocketClose(s);
	}
}