-
Declaration:
- Function Accept (Sock:Longint;Var Addr;Var Addrlen:Longint) : Longint;
-
Description:
- Accept accepts a connection from a socket Sock, which was listening for a connection. If a
connection is accepted, a file descriptor is returned. On error -1 is returned. The returned
socket may NOT be used to accept more connections. The original socket remains open.
The Accept call fills the address of the connecting entity in Addr, and sets its length in
Addrlen. Addr should be pointing to enough space, and Addrlen should be set to the amount
of space available, prior to the call.
-
Errors:
- On error, -1 is returned, and errors are reported in SocketError, and include the
following:
-
SYS__EBADF
- The socket descriptor is invalid.
-
SYS__ENOTSOCK
- The descriptor is not a socket.
-
SYS__EOPNOTSUPP
- The socket type doesn’t support the Listen operation.
-
SYS__EFAULT
- Addr points outside your address space.
-
SYS__EWOULDBLOCK
- The requested operation would block the process.
-
See also:
- Listen (668), Connect (663)
Listing: sockex/socksvr.pp
-
Declaration:
- Function Accept (Sock:longint;var addr:string;var SockIn,SockOut:text) :
Boolean;
-
Description:
- This is an alternate form of the Accept (660) command. It is equivalent to subsequently
calling the regular Accept (660) function and the Sock2Text (671) function. The function
returns True if successfull, False otherwise.
-
Errors:
- The errors are those of Accept (660).
-
See also:
- Accept (660)
-
Declaration:
- Function Accept (Sock:longint;var addr:string;var SockIn,SockOut:File) :
Boolean;
-
Description:
- This is an alternate form of the Accept (660) command. It is equivalent to subsequently
calling the regular Accept (660) function and the Sock2File (671) function. The Addr
parameter contains the name of the unix socket file to be opened. The function returns True
if successfull, False otherwise.
-
Errors:
- The errors are those of Accept (660).
-
See also:
- Accept (660)
-
Declaration:
- Function Accept (Sock:longint;var addr:TInetSockAddr;var
SockIn,SockOut:File) : Boolean;
-
Description:
- This is an alternate form of the Accept (660) command. It is equivalent to subsequently
calling the regular Accept (660) function and the Sock2File (671) function. The Addr
parameter contains the parameters of the internet socket that should be opened. The function
returns True if successfull, False otherwise.
-
Errors:
- The errors are those of Accept (660).
-
See also:
- Accept (660)
-
Declaration:
- Function Bind (Sock:Longint;Var Addr;AddrLen:Longint) : Boolean;
-
Description:
- Bind binds the socket Sock to address Addr. Addr has length Addrlen. The function returns
True if the call was succesful, False if not.
-
Errors:
- Errors are returned in SocketError and include the following:
-
SYS__EBADF
- The socket descriptor is invalid.
-
SYS__EINVAL
- The socket is already bound to an address,
-
SYS__EACCESS
- Address is protected and you don’t have permission to open it.
More arrors can be found in the Unix man pages.
-
See also:
- Socket (671)
-
Declaration:
- Function Bind (Sock:longint;const addr:string) : boolean;
-
Description:
- This is an alternate form of the Bind command. This form of the Bind command is
equivalent to subsequently calling Str2UnixSockAddr (672) and the regular Bind (662)
function. The function returns True if successfull, False otherwise.
-
Errors:
- Errors are those of the regular Bind (662) command.
-
See also:
- Bind (662)
-
Declaration:
- Function Connect (Sock:Longint;Var Addr;Addrlen:Longint) : Longint;
-
Description:
- Connect opens a connection to a peer, whose address is described by Addr. AddrLen contains
the length of the address. The type of Addr depends on the kind of connection you’re trying
to make, but is generally one of TSockAddr or TUnixSockAddr.
The Connect function returns a file descriptor if the call was successfull, -1 in case of error.
-
Errors:
- On error, -1 is returned and errors are reported in SocketError.
-
See also:
- Listen (668), Bind (662),Accept (660)
Listing: sockex/sockcli.pp
-
Declaration:
- Function Connect (Sock:longint;const addr:string;var SockIn,SockOut:text) :
Boolean;
-
Description:
- This is an alternate form of the Connect (663) command. It is equivalent to subsequently
calling the regular Connect (663) function and the Sock2Text (671) function. The function
returns True if successfull, False otherwise.
-
Errors:
- The errors are those of Connect (663).
-
See also:
- Connect (663)
-
Declaration:
- Function Connect (Sock:longint;const addr:string;var SockIn,SockOut:file) :
Boolean;
-
Description:
- This is an alternate form of the Connect (663) command. The parameter addr contains
the name of the unix socket file to be opened. It is equivalent to subsequently calling the
regular Connect (663) function and the Sock2File (671) function. The function returns True
if successfull, False otherwise.
-
Errors:
- The errors are those of Connect (663).
-
See also:
- Connect (663)
-
Declaration:
- Function Connect (Sock:longint;const addr: TInetSockAddr;var
SockIn,SockOut:file) : Boolean;
-
Description:
- This is another alternate form of the Connect (663) command. It is equivalent to
subsequently calling the regular Connect (663) function and the Sock2File (671) function. The
Addr parameter contains the parameters of the internet socket to connect to. The function
returns True if successfull, False otherwise.
-
Errors:
- The errors are those of Connect (663).
-
See also:
- Connect (663)
Listing: sockex/pfinger.pp
-
Declaration:
- Function GetPeerName (Sock:Longint;Var Addr;Var Addrlen:Longint) : Longint;
-
Description:
- GetPeerName returns the name of the entity connected to the specified socket Sock. The
Socket must be connected for this call to work. Addr should point to enough space to store
the name, the amount of space pointed to should be set in Addrlen. When the function
returns succesfully, Addr will be filled with the name, and Addrlen will be set to the length
of Addr.
-
Errors:
- Errors are reported in SocketError, and include the following:
-
SYS__EBADF
- The socket descriptor is invalid.
-
SYS__ENOBUFS
- The system doesn’t have enough buffers to perform the operation.
-
SYS__ENOTSOCK
- The descriptor is not a socket.
-
SYS__EFAULT
- Addr points outside your address space.
-
SYS__ENOTCONN
- The socket isn’t connected.
-
See also:
- Connect (663), Socket (671), connect (2)
-
Declaration:
- Function GetSocketName (Sock:Longint;Var Addr;Var Addrlen:Longint) :
Longint;
-
Description:
- GetSockName returns the current name of the specified socket Sock. Addr should point to
enough space to store the name, the amount of space pointed to should be set in Addrlen.
When the function returns succesfully, Addr will be filled with the name, and Addrlen will
be set to the length of Addr.
-
Errors:
- Errors are reported in SocketError, and include the following:
-
SYS__EBADF
- The socket descriptor is invalid.
-
SYS__ENOBUFS
- The system doesn’t have enough buffers to perform the operation.
-
SYS__ENOTSOCK
- The descriptor is not a socket.
-
SYS__EFAULT
- Addr points outside your address space.
-
See also:
- Bind (662)
-
Declaration:
- Function GetSocketOptions (Sock,Level,OptName:Longint;Var
OptVal;optlen:longint) : Longint;
-
Description:
- GetSocketOptions gets the connection options for socket Sock. The socket may be obtained from
different levels, indicated by Level, which can be one of the following:
-
SOL__SOCKET
- From the socket itself.
-
XXX
- set Level to XXX, the protocol number of the protocol which should interprete the
option.
For more information on this call, refer to the unix manual page getsockopt (2) .
-
Errors:
- Errors are reported in SocketError, and include the following:
-
SYS__EBADF
- The socket descriptor is invalid.
-
SYS__ENOTSOCK
- The descriptor is not a socket.
-
SYS__EFAULT
- OptVal points outside your address space.
-
See also:
- GetSocketOptions (667)
-
Declaration:
- Function Listen (Sock,MaxConnect:Longint) : Boolean;
-
Description:
- Listen listens for up to MaxConnect connections from socket Sock. The socket Sock must
be of type SOCK_STREAM or Sock_SEQPACKET. The function returns True if a connection was
accepted, False if an error occurred.
-
Errors:
- Errors are reported in SocketError, and include the following:
-
SYS__EBADF
- The socket descriptor is invalid.
-
SYS__ENOTSOCK
- The descriptor is not a socket.
-
SYS__EOPNOTSUPP
- The socket type doesn’t support the Listen operation.
-
See also:
- Socket (671), Bind (662), Connect (663)
-
Declaration:
- Function Recv (Sock:Longint;Var Addr;AddrLen,Flags:Longint) : Longint;
-
Description:
- Recv reads at most Addrlen bytes from socket Sock into address Addr. The socket must be in a
connected state. Flags can be one of the following:
-
1
- : Process out-of band data.
-
4
- : Bypass routing, use a direct interface.
-
??
- : Wait for full request or report an error.
The functions returns the number of bytes actually read from the socket, or -1 if a detectable error
occurred.
-
Errors:
- Errors are reported in SocketError, and include the following:
-
SYS__EBADF
- The socket descriptor is invalid.
-
SYS__ENOTCONN
- The socket isn’t connected.
-
SYS__ENOTSOCK
- The descriptor is not a socket.
-
SYS__EFAULT
- The address is outside your address space.
-
SYS__EMSGSIZE
- The message cannot be sent atomically.
-
SYS__EWOULDBLOCK
- The requested operation would block the process.
-
SYS__ENOBUFS
- The system doesn’t have enough free buffers available.
-
See also:
- Send (669)
-
Declaration:
- Function Send (Sock:Longint;Var Addr;AddrLen,Flags:Longint) : Longint;
-
Description:
- Send sends AddrLen bytes starting from address Addr to socket Sock. Sock must be in a
connected state. The function returns the number of bytes sent, or -1 if a detectable error occurred.
Flags can be one of the following:
-
1
- : Process out-of band data.
-
4
- : Bypass routing, use a direct interface.
-
Errors:
- Errors are reported in SocketError, and include the following:
-
SYS__EBADF
- The socket descriptor is invalid.
-
SYS__ENOTSOCK
- The descriptor is not a socket.
-
SYS__EFAULT
- The address is outside your address space.
-
SYS__EMSGSIZE
- The message cannot be sent atomically.
-
SYS__EWOULDBLOCK
- The requested operation would block the process.
-
SYS__ENOBUFS
- The system doesn’t have enough free buffers available.
-
See also:
- Recv (668), send (2)
-
Declaration:
- Function SetSocketOptions (Sock,Level,OptName:Longint;Var
OptVal;optlen:longint) : Longint;
-
Description:
- SetSocketOptions sets the connection options for socket Sock. The socket may be manipulated
at different levels, indicated by Level, which can be one of the following:
-
SOL__SOCKET
- To manipulate the socket itself.
-
XXX
- set Level to XXX, the protocol number of the protocol which should interprete the
option.
For more information on this call, refer to the unix manual page setsockopt (2) .
-
Errors:
- Errors are reported in SocketError, and include the following:
-
SYS__EBADF
- The socket descriptor is invalid.
-
SYS__ENOTSOCK
- The descriptor is not a socket.
-
SYS__EFAULT
- OptVal points outside your address space.
-
See also:
- GetSocketOptions (667)
-
Declaration:
- Function Shutdown (Sock:Longint;How:Longint) : Longint;
-
Description:
- ShutDown closes one end of a full duplex socket connection, described by Sock. How determines
how the connection will be shut down, and can be one of the following:
-
0
- : Further receives are disallowed.
-
1
- : Further sends are disallowed.
-
2
- : Sending nor receiving are allowed.
On succes, the function returns 0, on error -1 is returned.
-
Errors:
- SocketError is used to report errors, and includes the following:
-
SYS__EBADF
- The socket descriptor is invalid.
-
SYS__ENOTCONN
- The socket isn’t connected.
-
SYS__ENOTSOCK
- The descriptor is not a socket.
-
See also:
- Socket (671), Connect (663)
-
Declaration:
- Procedure Sock2File (Sock:Longint;Var SockIn,SockOut:File);
-
Description:
- Sock2File transforms a socket Sock into 2 Pascal file descriptors of type File, one for
reading from the socket (SockIn), one for writing to the socket (SockOut).
-
Errors:
- None.
-
See also:
- Socket (671), Sock2Text (671)
-
Declaration:
- Procedure Sock2Text (Sock:Longint;Var SockIn,SockOut: Text);
-
Description:
- Sock2Text transforms a socket Sock into 2 Pascal file descriptors of type Text, one for
reading from the socket (SockIn), one for writing to the socket (SockOut).
-
Errors:
- None.
-
See also:
- Socket (671), Sock2File (671)
-
Declaration:
- Function Socket (Domain,SocketType,Protocol:Longint) : Longint;
-
Description:
- Socket creates a new socket in domain Domain, from type SocketType using protocol
Protocol. The Domain, Socket type and Protocol can be specified using predefined constants
(see the section on constants for available constants) If succesfull, the function returns a
socket descriptor, which can be passed to a subsequent Bind (662) call. If unsuccesfull, the
function returns -1.
-
Errors:
- Errors are returned in SocketError, and include the follwing:
-
SYS__EPROTONOSUPPORT
- The protocol type or the specified protocol is not
supported within this domain.
-
SYS__EMFILE
- The per-process descriptor table is full.
-
SYS__ENFILE
- The system file table is full.
-
SYS__EACCESS
- Permission to create a socket of the specified type and/or protocol is
denied.
-
SYS__ENOBUFS
- Insufficient buffer space is available. The socket cannot be created until
sufficient resources are freed.
-
See also:
- SocketPair (672), socket (2)
for an example, see Accept (660).
-
Declaration:
- Function SocketPair (Domain,SocketType,Protocol:Longint;var
Pair:TSockArray) : Longint;
-
Description:
- SocketPair creates 2 sockets in domain Domain, from type SocketType and using protocol
Protocol. The pair is returned in Pair, and they are indistinguishable. The function returns
-1 upon error and 0 upon success.
-
Errors:
- Errors are reported in SocketError, and are the same as in Socket (671)
-
See also:
- Str2UnixSockAddr (672)
-
Declaration:
- Procedure Str2UnixSockAddr(const addr:string;var t:TUnixSockAddr;var
len:longint)
-
Description:
- Str2UnixSockAddr transforms a Unix socket address in a string to a TUnixSockAddr
structure which can be passed to the Bind (662) call.
-
Errors:
- None.
-
See also:
- Socket (671), Bind (662)