SESOCK |
|
SESOCK.DLL contains routines for opening and closing i/o sockets.
sock_errno |
Get the last error from any of the socket routines |
SYNTAX |
sock_errno() |
COMMENTS |
When a routine indicates an error return (usually SOCKET_ERROR),
you can call this to get the exact error number. Under UNIX, you can just
access 'errno' to get the same information. |
RETURN |
Returns the error number of the error in question. |
To the Top of this Page
Nombas' homepage
#link libraries
socket |
Create a socket and return it. |
SYNTAX |
int socket(port), int socket(host, port) |
COMMENTS |
Both calls create a socket and return it, returning
SOCKET_ERROR if it failed. Sockets are created in blocking mode by
default. Use ioctlsocket() to change back
to non-blocking mode.
The first syntax is used to create and monitor a local port for
connections. sockaccept() is used on the socket to create such a
connection. It is not valid to socksend()
or sockrecv() using this
socket since it is not connected to anything.
The second syntax connects to a remote machine via the specified port.
You cannot use sockaccept() on a socket created
with this call. |
To the Top of this Page
Nombas' homepage
#link libraries
sockaccept |
create and return a new socket |
SYNTAX
| int sockaccept(int socket[, string connection])
|
COMMENTS |
sockaccept() can only be used on a socket created to
monitor a port.
When a connection is ready, sockaccept() will create and return a new
socket which is the particular connection to a single remote address.
The original socket is still valid, and you can accept many times from
the single original socket. If the socket is in blocking mode, sockaccept()
will wait until a connection arrives if needed.
The connection parameter, if supplied, will be set to a string indicating
the IP address (numeric) of the connecting entity. This address is not
verified, so I believe it is relatively easy for a hacker to lie about this. |
To the Top of this Page
Nombas' homepage
#link libraries
closesocket |
Close a socket. |
SYNTAX |
void closesocket(socket) |
To the Top of this Page
Nombas' homepage
#link libraries
socksend |
Send some data on a socket. |
SYNTAX |
int socksend(socket, buffer[,length]) |
COMMENTS |
'length' bytes are sent from the given array of characters
(not null-terminated). If the length parameter is not provided, the string
is assumed to be null-terminated, and the entire string is sent. |
RETURN |
The number of bytes actually sent, or SOCKET_ERROR |
To the Top of this Page
Nombas' homepage
#link libraries
sockrecv |
Read some data from a socket, up to length bytes. |
SYNTAX |
int sockrecv(socket, buffer, length) |
COMMENTS |
The buffer is converted to a string if necessary and grown to
be able to hold all of the data transferred.
Note: under Windows, it is better to always do a sockselect() on the socket
before receiving any data. Otherwise, sockrecv() will wait for data, and no
Windows messages will be processed during this time. This may make your
application very unresponsive. |
RETURN |
Returns the number of bytes actually read or SOCKET_ERROR. |
To the Top of this Page
Nombas' homepage
#link libraries
sockselect |
Wait until one or more of the given sockets
are ready for reading/accepting. |
SYNTAX |
sockselect(timeout, socket,...) |
COMMENTS |
Any number of sockets can be specified, and an
array can be specified as well (It must be an array of sockets.)
The time-out is the number of milliseconds to wait before giving
up. If it is -1, wait indefinitely until some socket is ready. A
socket that has lost its connection will show up as ready (and
will return an error result when you try to use it.) |
RETURN |
Returns one of the sockets ready to be processed, or
SOCKET_ERROR if the timeout was reached. Currently, the first socket
you specified that is ready is returned, but this behavior is not
guaranteed. |
To the Top of this Page
Nombas' homepage
#link libraries
ioctlsocket |
Perform a standard operation on a socket. |
SYNTAX |
void ioctlsocket(socket, operation, parameter) |
COMMENTS |
You pass it the operation you would like to accomplish
and the parameter (usually 0 or non-0). The currently implemented
operations are:
FIONBIO - The parameter is 0 (makes the socket blocking)
or non-0 (makes the socket non-blocking). |
To the Top of this Page
Nombas' homepage
#link libraries
gethostname |
Get hostname of current machine. |
SYNTAX |
string gethostname() |
RETURN |
Returns the hostname of the current machine. |
To the Top of this Page
Nombas' homepage
#link libraries
Home |