TCPSocket Class Reference

[APE Index] [APE Hierarchy] [Headers]


reliable connected TCP stream sockets. More...

#include <socket.h>

Inherits: Socket

Public Members


Detailed Description

TCP sockets are used for stream based connected sessions between two sockets. Both error recovery and flow control operate transparently for a TCP socket connection.


TCPSocket(InetAddress &bind, short port, int backlog) [public]

A TCP "server" is created as a TCP socket that is bound to a hardware address and port number on the local machine and that has a backlog queue to listen for remote connection requests. If the server cannot be created, an exception is thrown.

Parameters:
backlog size of connection request queue.
port number to bind socket under.
bind local ip address or interface to use.

TCPSocket(InetHostAddress &host, short port) [public]

Create and connect a TCP socket to a bound TCP "server" on a specified host bound to a specified port number. If the socket cannot be connected, an exception is thrown.

Parameters:
port number on the host to connect through.
host address of internet host to connect with.

TCPSocket(TCPSocket &server) [public]

Create a TCP socket that is an "accepted" client connection from a TCP socket that has been bound as a server. This new socket is directly connected to the remote socket that had made a connection "request" into the servers backlog queue and can be thought of as being the APE method of performing an "accept()" call.

Parameters:
server socket to accept connection from.

TCPSocket(TCPSocket *server) [public]

Alternately create a TCP socket that is "accepted" from a casted pointer to a TCPSocket derived object acting as a bound TCP server. This new socket is directly connected to the remote socket that had made a connection "request" into the servers backlog queue.

Parameters:
server pointer to accept connection from.

TCPSocket(void) [public]

Create an unconnected TCP socket. Mostly for internal use.

bool OnAccept(InetHostAddress ia, short port) [public virtual]

A method to call in a derived TCPSocket class that is acting as a server when a connection request is being accepted. The server can implement protocol specific rules to exclude the remote socket from being accepted by returning false. The Peek method can also be used for this purpose.

Parameters:
ia internet host address of the client.
port number of the client.
Returns:
true if client should be accepted.

int Readline(char *buf, size_t max) [public]

Many TCP protocols involve the use of line oriented commands and data. The TCP readline method provides a very effecient means to read a single line of input from a TCP socket. This method does not use external buffering and is presumed safe from buffer overruns.

@len maximum number of bytes to read.

Parameters:
buf pointer to buffer.
Returns:
number of bytes read on success, -1 on error.

InetHostAddress getHost(short *port = NULL) [public]

Get the local socket address and port that the current socket has been bound to.

Parameters:
port pointer to store the port number socket uses.
Returns:
internet address of host interface for this socket.

InetHostAddress getPeer(short *port = NULL) [public]

Get the socket address of the remote socket that this socket is currently connected to.

Parameters:
port pointer to store the port number of the remote socket.
Returns:
internet address of remote internet host.

  • Author: David Sugar <dyfet@tycho.com>
  • Documentation generated by dyfet@home.sys on Thu Dec 16 09:54:26 EST 1999
Kdoc