Socket linked library
The socket library provides functions for IPv4 and IPv6 TCP/IP connection protocol,
which may be called from Cind programs.
To connect socket library use syntax of getting linked libraries,
with
For more about connecting libraries see Using linked libraries.
Functions
List of functions available from the socket library:
function | args | type of arguments | type of result | description |
connect | 2 | (string name,int port) | int | creates the socket and connects to given server on given port number, returns the socket as number. |
send | 4 | (int socket,sheet data,int off,int count) | int | sends a data on a socket, returns number of bytes sent. |
recv | 3 | (int socket,sheet data,int count) | int | receives a data from a socket, returns number of bytes received. |
shutdown | 2 | (int socket,int how) | - | shut down part of the connection. 'how' parameter values: 1 - close receiving, 2 - close sending, 3 - close both. |
close | 1 | (int socket) | - | closes a socket. |
bind | 1 | (int port) | int | creates the socket and bind to given port number, returns the socket as number. |
listen | 2 | (int socket,int qsize) | - | listen for connection on a given socket, setting also the length of waiters queue. |
accept | 1 | (int socket) | int | accepts another incomming connection, returns the socket of the new connection. |
getPeerHost | 3 | (int socket,int ipv,sheet name) | int | gets the IP number of the connection, the 'ipv' parameter should be 4 or 6, saying, that resuling string must be in IPv4 or IPv6 format, returns number of written bytes. |
getPeerPort | 3 | (int socket) | int | returns the port number of the connection of given socket. |
Remarks:
Example of usage