SocketError SocketBind(
Socket s,
SocketPort p,
SocketBindFlags flags);
Use the
SocketBind()
routine to associate a socket with a port number on this side of the connection.
For any given domain, normally only one socket on the machine may be bound to any port number. If you have used
SocketBind()
to bind some other socket to this port, then you may only bind another socket to the port by setting the SBF_REUSE_PORT in the flags argument. If you have used
SocketBindInDomain()
to bind some other socket to this port, then you may not use
SocketBind()
to bind another socket to the port.
A given socket may only be bound to one port.
This routine takes the following arguments:
If successful, the routine will return SE_NORMAL (i.e., zero). Otherwise, it will return some other
SocketError
value. Be on the lookout for SE_SOCKET_ALREADY_BOUND, SE_PORT_IN_USE, or SE_BIND_CONFLICT.
See Also: SocketBindInDomain().
Include: socket.goh
SocketError SocketBindInDomain(
Socket s,
SocketPort p,
SocketBindFlags flags,
TCHAR *domain);
Use the
SocketBindInDomain()
routine to associate a socket with a port number and domain on this side of the connection.
For any given domain, normally only one socket on the machine may be bound to any port number in any given domain. If you have used
SocketBindInDomain()
to bind some other socket to this port and domain, then you may only bind another socket to the port and domain by setting the SBF_REUSE_PORT in the flags argument. If you have used
SocketBind()
to bind some other socket to this port, then you may not use
SocketBindInDomain()
to bind another socket to the port.
A given socket may only be bound to one port.
This routine takes the following arguments:
If successful, the routine will return SE_NORMAL (i.e., zero). Otherwise, it will return some other
SocketError
value. Be on the lookout for SE_SOCKET_ALREADY_BOUND, SE_PORT_IN_USE, or SE_BIND_CONFLICT.
See Also: SocketBind().
Include: socket.goh
int SocketCheckListen(
SocketPort p,
TCHAR *domain,
int bufsize);
Use the
SocketCheckListen()
command on a port to find out the domain for the first connect request on a listening socket--that is, the first connection request which has not yet been accepted. You might think of this as a limited form of "caller ID"--a chance to find out a bit about the incoming connection before you accept it. If
SocketCheckListen()
returns SE_PORT_NOT_LISTENING, it means that you have not passed it a port to which a socket is listening.
This routine takes the following arguments:
It returns the length of the domain name. If the return value is zero, there was an error. Look out for SE_PORT_NOT_LISTENING, which signals that there is no socket bound to the port in question which is listening.
See Also: SocketBind(),
SocketBindInDomain(),
SocketListen().
Include: socket.goh
int SocketCheckReady(
SocketCheckRequest *requests,
int numRequests,
int timeout);
To check one or more sockets to see if they have received data, received connection requests, or are ready to write, call
SocketCheckReady()
. It can check connections for incoming data or just incoming urgent data.
For programs which need to poll many sockets,
SocketCheckReady()
provides a tidy means to do this without spawning a thread for each socket.
The
SocketCheckReady()
routine takes an array of
SocketCheckRequest
structures. Each one of these structures contains a socket and a condition.
SocketCheckReady()
looks at each
SocketCheckRequest
structure in the array and returns the index of the first structure whose socket meets the condition.
Thus, to determine if a given socket is properly set-up so that you can send data through it, you would pass
SocketCheckReady()
a one-element array (represented in pseudo-code):
{ mySocket, SC_WRITE, 0 }
To check several sockets to see whether any of them had received any connection requests, pass
SocketCheckReady()
an array of the form (represented in pseudo-code):
{ socket1, SC_ACCEPT, 0 },
{ socket2, SC_ACCEPT, 0 },
{ socket3, SC_ACCEPT, 0 }
For any socket, you may check for one or more of the following conditions:
If you query a socket about a condition that does not apply to its current state (e.g., ask a non-listening socket if it is ready to accept), then
SocketCheckReady()
will return SE_IMPROPER_CONDITION.
This routine takes the following arguments:
SocketCheckRequests
structures, as described above.
The routine returns the index of the first
SocketCheckRequest
to meet its conditions.
Include: socket.goh
GEOS SDK TechDocs
|
|
SGC_MACHINE ...
|
SocketClose() ...