Function Connect (Sock:longint;const addr: TInetSockAddr;var SockIn,SockOut:file) : Boolean;
This is another alternate form of the Connect command. It is equivalent to subsequently calling the regular Connect function and the Sock2File function. The Addr parameter contains the parameters of the internet socket to connect to.
The function returns True if successfull, False otherwise.
The errors are those of Connect.
program pfinger; uses sockets,errors; Var Addr : TInetSockAddr; S : Longint; Sin,Sout : Text; Line : string; begin Addr.family:=AF_INET; { port 78 in network order } Addr.port:=79 shl 8; { localhost : 127.0.0.1 in network order } Addr.addr:=((1 shl 24) or 127); S:=Socket(AF_INET,SOCK_STREAM,0); If Not Connect (S,ADDR,SIN,SOUT) Then begin Writeln ('Couldn''t connect to localhost'); Writeln ('Socket error : ',strerror(SocketError)); halt(1); end; rewrite (sout); reset(sin); writeln (sout,paramstr(1)); flush(sout); while not eof(sin) do begin readln (Sin,line); writeln (line); end; close (sin); close (sout); end.