The UNIX Operating System

TOP

UP


Ray Seyfarth

ORCA


Computer Science

COST

USM




Connecting to a Server with TCP


    NAME
           connect - initiate a connection on a socket
    
    SYNOPSIS
           #include <sys/types.h>
           #include <sys/socket.h>
    
           int connect(int s, struct sockaddr
                       *serv_addr, int addrlen );
    
    RETURN VALUE
           If the connection or binding succeeds, zero  is  returned.
           On  error, -1 is returned, and errno is set appropriately.
    

  • We will use a sockaddr_in structure (possibly cast)

  • After connect, s is available to read/write


University of Southern Mississippi
Ray.Seyfarth@usm.edu
Updated 20:05 Jun 5, 2000