TCP/IP Programming Manual
/* Program must contain code to create the socket fd
* and to fill in the remote address before calling connect.
*/
...
if (connect (fd,(struct sockaddr *)&remote,sizeof(remote)) <0) {
perror ("Client failed to connect to remote host.");
exit (0);
}
printf ("CLIENT:Connected ...\n");
INET6: The following programming example calls the connect routine that connects the socket
fd to a remote socket. The remote structure contains the address and port of the remote socket:
#include <socket.h>
#include <in.h>
#include <in6.h>
#include <netdb.h>
...
struct sockaddr_in6 remote;
....
/* Program must contain code to create the socket fd
* and to fill in the remote address before calling connect.
*/
...
/*Notice that remote is cast as struct sockaddr as suggested in
the Usage Guidelines */
if (connect (fd,(struct sockaddr *)&
remote,sizeof(remote)) <0) {
perror ("Client failed to connect to remote host.");
exit (0);
}
printf ("CLIENT:Connected ...\n");
freeaddrinfo
The freeaddrinfo function frees the memory of one or more addrinfo structures previously
created by the getaddrinfo function. Any dynamic storage pointed to by the structure is also
freed. (This function is supported for NonStop TCP/IPv6 only.)
C Synopsis
#include <netdb.h>
void freeaddrinfo (struct addrinfo *ai);
TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
freeaddrinfo (ai);
INT .EXT ai (addrinfo);
ai
input value; specifies the addrinfo structure to be freed.
Errors
No errors are returned for this function.
104 Library Routines