Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ connect(2X) — UNIX 2.9BSD

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

accept(2x)

select(2x)

socket(2x)

CONNECT(2X)  —  Unix Programmer’s Manual

NAME

connect − initiate a connection on a socket

SYNOPSIS

#include <sys/socket.h> connect(s, addr)
int s;
struct sockaddr ∗addr;

DESCRIPTION

Connect causes a connection request to be initiated to the entity at addr using the underlying protocol of the socket s.  When the connection completes, a zero value is returned. 

If the socket is non-blocking (see ioctlnew(2x)) but the connection cannot be completed immediately, then the call returns −1 and sets the external variable errno to EWOULDBLOCK. It is possible to select(2x) a socket which is connecting by selecting it for writing, since writing is not possible before the connection completes.

If the socket is alreay connected, a value of −1 is returned and errno is set to EISCONN.  Failure to connect often results in ETIMEDOUT or EREFUSED errors.  Other errors are also possible. 

SEE ALSO

accept(2x), select(2x), socket(2x)

BUGS

A socket’s state is not properly restored if a connect fails; for the time being you can close the socket and recreate it to get around the bug. 

This call is provisional and will exist in a slightly different form in 4.2bsd. 

7th Edition  —  3/17/82

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026