uocis  CIS 432/532 Introduction to Computer Networks - Fall 2003


Using connect(2)

The connect() call sets the remote address and port of a socket.


#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <stdio.h>

...

int err;
struct sockaddr_un remote_addr;

remote_addr.sun_family = AF_UNIX;
strcpy (remote_addr.sun_path, "/tmp/server-sock");

err = connect (s, (struct sockaddr *) &remote_addr, sizeof remote_addr);
if (err < 0) perror ("connect failed");


Created by: Daniel Stutzbach December 15, 2003