Connecting To A Server After we create the socket, we need to connect it to the server. This is required because the TCP protocol is connection oriented. /* now connect to the remote server. the system will */ /* choose a free port number for the local side of the */ /* connection. */ /* note the cast to a struct sockaddr pointer of the */ /* address of variable 'sa'. */ if (connect(s, (struct sockaddr *)&sa, sizeof(sa)) ) { perror("connect"); exit(1); }