MarshallSoft

dBase TCP (Client/Server) Example


* connect to TCP server and read it's greeting message

Function ConnectToServer(Server, Port, Buffer, BufLen) Local Code
Local DataSock
* the client connects to the server
DataSock = cscClient(Server, Port)
* error ? (negative return codes are errors)
if DataSock < 0
  return DataSock
endif
* wait (3 sec) for greeting message from server
if cscAwaitData(DataSock, 3000) <> 0
  * read server's greeting message into Buffer
  Code = cscGetData(DataSock, Buffer, BufLen)
  if Code < 0
    return Code
  endif
  * return (virtual) data socket
  return DataSock
endif
* timed out
return CSC_CONNECT_TIMEOUT

MSC Logo

HOME PAGE
MARSHALLSOFT is a trademark of MarshallSoft Computing, Inc.