Metrologic Optimus S Programming Manual page 152

"c" programming guide
Table of Contents

Advertisement

146
"C" Programming Guide For Optimus S/R
closesocket
memset (&name, 0, sizeof (name));
name.sin_family = AF_INET;
name.sin_port = htons (3000);
if (bind (s, (struct sockaddr*) &name, sizeof (name)) < 0) {
printf ("Error in Binding on socket: %d", s);
.....................
}
Description
This routine binds the local IP address and listening port number information to
the socket specified.
For connection-oriented sockets (passive open), this routine must be called
before calling listen() and accept().
The socket specified must be a valid descriptor returned from a previous
call to the socket() routine.
The local IP address specified can be left out as 0. The application can use
getsockname() to learn the address and port that has been assigned to it.
If it is other than 0, this routine will verify this information against the
actual local IP address of the local terminal.
Return
If successful, it returns 0.
On error, it returns -1.
The global variable errno is set to indicate the error condition encountered.
See Also
connect, getsockname, listen, socket
Purpose
To close a socket.
Syntax
int closesocket (SOCKET s);
s
SOCKET s;
Example
..............
if (closesocket (s) < 0) {
printf ("closesocket fails on socket: %d", s);
...................
}
Description
This function closes socket and releases the connection block.
Return
If successful, it returns 0.
On error, it returns -1.
The global variable errno is set to indicate the error condition encountered.
shutdown, socket
See Also
Descriptor identifying a socket

Advertisement

Table of Contents
loading

This manual is also suitable for:

Optimus r

Table of Contents