Function ConnectToServer(cServer, nPort, cBuffer, nBufLen)
* connect to TCP server and read it's greeting message
Local nCode
Local nDataSock
* the client connects to the server
nDataSock = XcscClient(@cServer, nPort)
* error ? (negative return codes are errors)
if nDataSock < 0
return nDataSock
endif
* wait (3 sec) for greeting message from server
if XcscAwaitData(nDataSock, 3000) <> 0
* read server's greeting message into cBuffer
nCode = XcscGetData(nDataSock, @cBuffer, nBufLen)
if nCode < 0
return nCode
endif
* return (virtual) data socket
return nDataSock
endif
* timed out
return CSC_CONNECT_TIMEOUT
HOME PAGE
MARSHALLSOFT is a trademark of MarshallSoft Computing, Inc.