{The SERVER program must be run first. Otherwise a NET_CONNECT() error 20 will result.} program host; uses pctcp; var d:word; as:addr; e:word; sa,aa:word; w:word; buffer:array[1..100] of char; begin if not pctcp_installed then begin writeln('PCTCP not installed'); halt; end; as.IP_addr.a := 149; {Assign values for server address} as.IP_addr.b := 160; {If the server address is unknown, the client} as.IP_addr.c := 6; {must look it up in the DNS with NM_RES_NAME()} as.IP_addr.d := 11; as.remote_socket := $6666; {Well known port for connection to server} as.local_socket := $0000; {Force automatic allocation of local port} as.protocol := protocol_stream; {Specify TCP as protocol} writeln('Attempting to connect'); d:=$ffff; {Force automatic allocation of descriptor} net_connect(d,protocol_stream,as,e); if e<>0 then begin writeln('net_connect:',e); halt; end; sa:=seg(buffer); aa:=ofs(buffer); {Set up pointers to buffer} net_read(d,100,0,sa,aa,as,w,e); {Block and wait to receive information} writeln('net_read:',tcp_error[e]); if e<>0 then halt; writeln('net_read success:',w); {W = number of bytes actually read} for e := 1 to w do write(buffer[e]); {Display ONLY information received} net_eof(d,e); {Close transmition side of connection} writeln('net_eof:',tcp_error[e]); if e<>0 then halt; net_release(d,e); {Release descriptor} writeln('net_release:',e); if e<>0 then halt; writeln('Done.'); end.