NAME
src/pmc/socket.pmc - Socket PMC
DESCRIPTION
The Socket PMC performs network I/O operations.
Vtable Functions
void init()
Initializes a newly created Socket object.
PMC *clone()
Create a copy of the socket handle.
INTVAL does(STRING * role)
void mark()
Mark active socket handle data as live.
void destroy()
Free structures.
INTVAL get_bool()
Returns whether the Socket is currently open.
Methods
socket
sockaddr
connect
Connects a socket object to an address.The asynchronous version takes an additional final PMC callback argument,
and only returns a status object.
When the socket operation is complete,
it invokes the callback,
passing it a status object and the socket object it was called on.
[If you want notification when a connect operation is completed,
you probably want to do something with that connected socket object.]
close
Close a socket.
recv
Receives a message from a connected socket object.
It returns the message in a string.The asynchronous version takes an additional final PMC callback argument,
and only returns a status object.
When the recv operation is complete,
it invokes the callback,
passing it a status object and a string containing the received message.
send
Sends a message string to a connected socket object.The asynchronous version takes an additional final PMC callback argument,
and only returns a status object.
When the send operation is complete,
it invokes the callback,
passing it a status object.
bind
listen
accept
sockaddr
returns an object representing a socket address,
generated from a port number (integer) and an address (string).
bind
binds a socket object to the port and address specified by an address object (the packed result of sockaddr
).The asynchronous version takes an additional final PMC callback argument,
and only returns a status object.
When the bind operation is complete,
it invokes the callback,
passing it a status object and the socket object it was called on.
[If you want notification when a bind operation is completed,
you probably want to do something with that bound socket object.]
listen
specifies that a socket object is willing to accept incoming connections.
The integer argument gives the maximum size of the queue for pending connections.There is no asynchronous version.
listen
marks a set of attributes on the socket object.
accept
accepts a new connection on a given socket object,
and returns a newly created socket object for the connection.The asynchronous version takes an additional final PMC callback argument,
and only returns a status object.
When the accept operation receives a new connection,
it invokes the callback,
passing it a status object and a newly created socket object for the connection.
[While the synchronous accept
has to be called repeatedly in a loop (once for each connection received),
the asynchronous version is only called once,
but continues to send new connection events until the socket is closed.]