{The address of the server must be known to all clients wishing to access it. If the server has a registered domain-name, the address may be extracted from the DNS server. IP does not support a method of broadcasting to all nodes to search for a specific server. IP does support broadcasting for a particular LAN. The Broadcast address can be obtained by calling GET_CONFIGURATION_INFORMATION and examining the field IP_BROADCAST_ADR. The broadcast must be sent using IP, UDP, or TCP; connections cannot be established to the broadcast address (any attempt hangs the host).} program server; uses pctcp; var d:word; as:addr; e:word; sa,aa:word; w:word; buffer:array[1..17] of char; procedure info; var r:TCP_connection_stats; begin net_stat_TCP(r,e); writeln('Error:',tcp_error[e]); writeln('Bytes Sent:',r.bytes_sent); writeln('Bytes Received:',r.bytes_received); writeln('Packets Sent:',r.packets_sent); writeln('Packets Received',r.packets_received); writeln('Bad Checksums:',r.bad_checksums); writeln('Window Count',r.window_count); writeln('Timouts:',r.timeouts); writeln('resets:',r.resets); writeln('Dup Packets:',r.duplicate_packets); writeln('Retrans:',r.retranmitions); end; begin if not pctcp_installed then begin writeln('PCTCP not installed'); halt; end; as.local_socket := $6666; {Must be "well-known" to all clients} as.protocol := protocol_stream; {Specifies TCP as protocol} net_getdesc(d,e); {Allocate descriptor for use} if e<>0 then begin writeln('net_getdesc:',e); halt; end; {d:=$ffff; {Forces automatic allocation of descriptor on call to net_listen} net_getdesc(d,e);{automatic allocation doesn't appear to work} net_listen(d,protocol_stream,as,e); if e<>0 then begin writeln('net_listen:',e); halt; end else begin {These fields are automatically filled in by the call to net_listen} write('Connected to host ',as.IP_addr.a,'.',as.IP_addr.b,'.', as.IP_addr.c,'.',as.IP_addr.d); writeln('. On port ',as.remote_socket); writeln('Using descriptor ',d); end; info; buffer := 'you are connected'; {Data to send} sa:=seg(buffer); aa:=ofs(buffer); {Set up pointers to data} net_write(d,17,0,sa,aa,w,e); {Send data} if e<>0 then begin writeln('net_write:',e); halt; end else writeln('net_write success:',w); {w = number of chars actually written} net_eof(d,e); {Close send side of connection} if e<>0 then begin writeln('net_eof:',e); halt; end; net_release(d,e); {Release the descriptor} if e<>0 then begin writeln('net_release:',e); halt; end; writeln('Done.'); end.