Chapter 3 Terminal Specific Function Library
145
Description
This routine is used by a server application to perform a passive open,
permitting a connection request from client.
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 socket will remain in the listening state until a client establishes a
connection with the port offered by the server.
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.
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.
See Also
connect, listen, select
bind
Purpose
To bind a name to a newly created socket.
Syntax
int bind (SOCKET s, struct sockaddr *name, int namelen);
s
Descriptor identifying an unbound socket
name
Pointer to a sockaddr structure containing the local IP address
and listening port to be bounded
namelen
Integer specifying the length of
name
Example
SOCKET s;
struct sockaddr_in name;
s = socket (PF_INET, SOCK_STREAM, TCP);
if (s < 0) {
printf ("SOCKET allocation failed");
.....................
}
Содержание Optimus R
Страница 1: ...Printed on 20 March 2006 C Programming Guide Version 3 04 02 Optimus S Optimus R...
Страница 6: ......
Страница 8: ...2 C Programming Guide For Optimus S R...
Страница 12: ...6 C Programming Guide For Optimus S R The flow is illustrated as shown below...
Страница 23: ...Chapter 2 Development Environment 17 Different types signed unsigned Different types same size...
Страница 24: ...18 C Programming Guide For Optimus S R...
Страница 220: ...214 C Programming Guide For Optimus S R See Also FlashSize free_memory...
Страница 232: ...226 C Programming Guide For Optimus S R 4 11 Implementation defined Limits limits h float h Refer to limit h and float h...
Страница 238: ...232 C Programming Guide For Optimus S R...