up previous next
OpenSocket --
open a socket connection
|
OpenSocket(HostName: STRING, PortNum: INT): RECORD |
This function opens a client socket (I/O) connection to port
PortNum
on the computer
HostName; to make a connection to the same computer
CoCoA is running on specify the host name
localhost.
The result is a
RECORD where the field
send is an
out-stream,
and the field
recv is an
in-stream. The expectation is that a
remote procedure call is sent on
send, and the result is read from
recv using the function
GetLine
.
The first arg
HostName is a string containing the name of the
computer which is waiting for a connection; the second arg
PortNum
is the
port number at which the server is waiting.
An error will be signalled if the computer
HostName is not waiting
for a connection to port
PortNum. The obsolete CoCoAServer waits for
a connection on the port number 49344 (which is
c0c0 in hexadecimal).
/**/ --> assuming an echo server is waiting on port 50000...
/**/ IOPair := OpenSocket("localhost", 50000);
/**/ PrintLn 123+456 On IOPair.send;
/**/ str := GetLine(IOPair.recv);
/**/ str;
579
|