Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::TCPSocket Class Reference

A socket class that represents a TCP socket. More...

#include <vcf/NetworkKit/Socket.h>

Inheritance diagram for VCF::TCPSocket:

VCF::Socket VCF::Object List of all members.

Public Member Functions

 TCPSocket ()
 Creates an unconnected socket in stStream mode.
 TCPSocket (unsigned short port)
 Creates a bound and listening socket in stStream mode.
 TCPSocket (const String &host, unsigned short port)
 Creates a connected socket in stStream mode.
virtual ~TCPSocket ()

Protected Member Functions

 TCPSocket (SocketPeer *peer)
 Creates a socket from an existing peer intance.

Friends

class Socket

Detailed Description

A socket class that represents a TCP socket.

Useful for creating a TCP based client or server socket. A simple example for a server might be something like this:

    TCPSocket server;
    server.listen( 1234 );

    while ( true ) {
        Socket* client = server.accept();

        {
            TCPSocketOutputStream sos( *client );
            unsigned char bytes[256];
            //put some data in the bytes variable...

            //write to the client socket
            sos.write( bytes, sizeof(bytes) );
        }

    }


Constructor & Destructor Documentation

VCF::TCPSocket::TCPSocket  ) 
 

Creates an unconnected socket in stStream mode.

VCF::TCPSocket::TCPSocket unsigned short  port  ) 
 

Creates a bound and listening socket in stStream mode.

VCF::TCPSocket::TCPSocket const String host,
unsigned short  port
 

Creates a connected socket in stStream mode.

A connection is automatically made to the specified host and port.

virtual VCF::TCPSocket::~TCPSocket  )  [inline, virtual]
 

VCF::TCPSocket::TCPSocket SocketPeer peer  )  [inline, protected]
 

Creates a socket from an existing peer intance.

This is used primarily by the accept() method.


Friends And Related Function Documentation

friend class Socket [friend]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information