Cross-Platform C++

ot::net
class SocketFactory

#include "ot/net/SocketFactory.h"

ot::ManagedObject ot::ssl::SSLSocketFactory A factory class for creating instances of Socket. A default implementation of SocketFactory is provided which simply creates instances of the Socket class. However, the SocketFactory interface may be employed by applications (and elsewhere within OpenTop) to create customized derivatives of the Socket class.

Multi-threaded considerations:
Can safely be called from multiple concurrent threads.
Since:
OpenTop 1.4



Method Summary
 virtual RefPtr< Socket > createSocket()
         Creates an unconnected Socket.
 virtual RefPtr< Socket > createSocket(InetAddress* pAddress, int port)
         Creates a Socket and connects it to the specified port on the network host designated by the provided InetAddress.
 virtual RefPtr< Socket > createSocket(const String& host, int port)
         Creates a Socket that is connected to a specified host name and port.
 virtual RefPtr< Socket > createSocket(InetAddress* pAddress, int port, InetAddress* pLocalAddr, int localPort)
         Creates a Socket and connects it to the specified remote port on the network host designated by the provided InetAddress.
 virtual RefPtr< Socket > createSocket(const String& host, int port, InetAddress* pLocalAddr, int localPort)
         Creates a Socket that is connected to a specified host name and port.
static RefPtr< SocketFactory > GetDefault()
         Returns the default implementation of the SocketFactory class.

Methods inherited from class ot::ManagedObject
addRef(), getRefCount(), onFinalRelease(), operator=(const ManagedObject&), release()

Method Detail

createSocket

virtual RefPtr< SocketcreateSocket()
Creates an unconnected Socket. Before the socket can be used to communicate with an end-point, it must first be connected using Socket::connect().

Exceptions:
SocketException - if an error occurs creating the Socket.

createSocket

virtual RefPtr< SocketcreateSocket(InetAddress* pAddress,
                                      int port)
Creates a Socket and connects it to the specified port on the network host designated by the provided InetAddress.

Parameters:
pAddress - the IP Address of the remote host.
port - the port on the remote host.
Exceptions:
SocketException - if an error occurs creating or connecting the socket.
NullPointerException - if pAddress is null.

createSocket

virtual RefPtr< SocketcreateSocket(const String& host,
                                      int port)
Creates a Socket that is connected to a specified host name and port. The host name is first resolved into an InetAddress before connecting to it.

Parameters:
host - the name of the remote host or a string representation of its IP-address in the form "xxx.xxx.xxx.xxx".
Exceptions:
UnknownHostException - if host cannot be resolved into an Internet address.
SocketException - if an error occurs creating or connecting the socket.

createSocket

virtual RefPtr< SocketcreateSocket(InetAddress* pAddress,
                                      int port,
                                      InetAddress* pLocalAddr,
                                      int localPort)
Creates a Socket and connects it to the specified remote port on the network host designated by the provided InetAddress. The created Socket is bound to the specified local port and InetAddress.

If pLocalAddr is null, the socket is bound to any interface on the local host. If localPort is 0, the operating system chooses an unused local port number.

Parameters:
pAddress - the InetAddress of the remote host.
port - the port number on the remote host.
pLocalAddr - the local network interface to connect from.
localPort - the local port number to use, or zero for a system-assigned port. On UNIX systems, a port number below 1025 requires special system privileges.
Exceptions:
NullPointerException - if pAddress is null.
SocketException - if an error occurs creating, binding or connecting the socket.

createSocket

virtual RefPtr< SocketcreateSocket(const String& host,
                                      int port,
                                      InetAddress* pLocalAddr,
                                      int localPort)
Creates a Socket that is connected to a specified host name and port. The created Socket is bound to the specified local port and network interface.

The host name is first resolved into an InetAddress before connecting to it.

Parameters:
host - the name of the remote host or a string representation of its IP-address in the form "xxx.xxx.xxx.xxx".
port - the port number on the remote host.
pLocalAddr - the local network interface to connect from.
localPort - the local port number to use, or zero for a system-assigned port. On UNIX systems, a port number below 1025 requires special system privileges.
Exceptions:
UnknownHostException - if host cannot be resolved into an Internet address.
SocketException - if an error occurs creating, binding or connecting the socket.

GetDefault

static RefPtr< SocketFactory > GetDefault()
Returns the default implementation of the SocketFactory class. The default implementation can be used to create instances of the Socket class.

Multi-threaded considerations:
Can safely be called from multiple concurrent threads.


Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2005 ElCel Technology   Trademark Acknowledgements