Metrologic Optimus S Programming Manual page 151

"c" programming guide
Table of Contents

Advertisement

Description
This routine is used by a server application to perform a passive open,
permitting a connection request from client.
The socket will remain in the listening state until a client establishes a
connection with the port offered by the server.
Note that this is a blocking function. This routine will not return unless there is
error or a new connection is established. If normal program flow is mandatory
for the application or the application is going to accept multiple connection
requests. This routine must be called in a separate task.
Return
If successful, it returns a non-negative integer (>=0) as a descriptor for the
accepted socket.
On error, it returns -1.
The global variable errno is set to indicate the error condition encountered.
connect, listen, select
See Also
bind
Purpose
To bind a name to a newly created socket.
Syntax
int bind (SOCKET s, struct sockaddr *name, int namelen);
s
name
namelen
Example
SOCKET s;
struct sockaddr_in name;
s = socket (PF_INET, SOCK_STREAM, TCP);
if (s < 0) {
}
Chapter 3 Terminal Specific Function Library
The name is a result parameter that is filled in with the address of the
connecting entity, as known to the communications layer. The exact
format of the name parameter is determined by the address family in
which the communication is occurring.
The namelen is a value-result parameter; it initially contains the amount of
space pointed to by name; on return, it will contain the actual length, in
bytes, of the address returned. The name is truncated if the buffer provided
is too small. (?)
The connection is actually made with the socket that is returned by this
routine.
The original socket remains in the listening state, and can be used in a
subsequent call to this routine to provide additional connections.
Descriptor identifying an unbound socket
Pointer to a sockaddr structure containing the local IP address
and listening port to be bounded
Integer specifying the length of name
printf ("SOCKET allocation failed");
.....................
145

Advertisement

Table of Contents
loading

This manual is also suitable for:

Optimus r

Table of Contents