Metrologic Optimus S Programming Manual page 156

"c" programming guide
Table of Contents

Advertisement

150
"C" Programming Guide For Optimus S/R
getsockname
printf ("Can not get remote name info");
.......................
}
This routine returns the name of the peer connected to socket s. It only can be
Description
used on a connected socket. (?)
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.
If successful, it returns 0.
Return
On error, it returns -1.
The global variable errno is set to indicate the error condition encountered.
See Also
connect, getsockname
Purpose
To get socket name.
Syntax
int getsockname (SOCKET s, struct sockaddr *name, int *namelen);
s
name
namelen
Example
SOCKET s;
struct sockaddr_in local_name;
int size_of_name;
........................
size_of_name = sizeof (local_name);
if (getsockname (s, (struct sockaddr*) &local_name, &size_of_name) < 0) {
printf ("Can not get local name info");
.......................
}
Description
This routine returns the current name for bound or connected socket s. It is
especially useful when a connect() call has been made without doing a bind
first. (?)
Descriptor identifying a socket
Pointer to a sockaddr structure receiving the local IP address
and port number
Pointer to an integer containing the length of name

Advertisement

Table of Contents
loading

This manual is also suitable for:

Optimus r

Table of Contents