OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Using a Stream Server
  1. Create a stream socket:
    TStreamSocket socket(TINetSocketAddress(htons(2000), INADDR_ANY);
    socket.CreateSocket();
  2. Bind the socket to a well-known name (bind()):
    socket.BindSocket();
  3. Listen for connections (listen()):
    socket.Listen();
  4. Accept a connection (accept()):
    TStreamSocket client;
    socket.Accept(client);
  5. To write (send()):
    socket.Write("Hello");
  6. To read (recv()):
    char buffer[80];
    socket.Read(buffer, sizeof(buffer));
  7. Close the socket (closesocket())
    socket.CloseSocket();