ObjFW
Public Member Functions | Protected Attributes
OFTCPSocket Class Reference

A class which provides functions to create and use TCP sockets. More...

#include <OFTCPSocket.h>

Inheritance diagram for OFTCPSocket:
OFStreamSocket OFStream OFObject <OFObject>

List of all members.

Public Member Functions

void connectToHost:onPort: (OFString *host,[onPort] uint16_t port)
uint16_t bindToPort:onHost: (uint16_t port,[onHost] OFString *host)
void listenWithBackLog: (int backlog)
void listen ()
OFTCPSocketaccept ()
void setKeepAlivesEnabled: (BOOL enable)
OFStringremoteAddress ()
BOOL isListening ()

Protected Attributes

BOOL isListening
struct sockaddr_storage * sockAddr
socklen_t sockAddrLen

Detailed Description

A class which provides functions to create and use TCP sockets.

To connect to a server, create a socket and connect it. To create a server, create a socket, bind it and listen on it.


Member Function Documentation

OFTCPSocket * OFTCPSocket::accept ( ) [virtual]

Accept an incoming connection.

Returns:
An autoreleased OFTCPSocket for the accepted connection.
uint16_t OFTCPSocket::bindToPort:onHost: ( uint16_t  port,
[onHost] OFString host 
) [virtual]

Bind the socket on the specified port and host.

Parameters:
portThe port to bind to. If the port is 0, an unused port will be chosen, which can be obtained using the return value.
hostThe host to bind to. Use "0.0.0.0" for IPv4 or @"::" for IPv6 to bind to all.
Returns:
The port the socket was bound to
void OFTCPSocket::connectToHost:onPort: ( OFString host,
[onPort] uint16_t  port 
) [virtual]

Connect the OFTCPSocket to the specified destination.

Parameters:
hostThe host to connect to
portThe port on the host to connect to
BOOL OFTCPSocket::isListening ( ) [virtual]
Returns:
Whether the socket is a listening socket
void OFTCPSocket::listen ( ) [virtual]

Listen on the socket.

void OFTCPSocket::listenWithBackLog: ( int  backlog) [virtual]

Listen on the socket.

Parameters:
backlogMaximum length for the queue of pending connections.
OFString * OFTCPSocket::remoteAddress ( ) [virtual]

Returns the remote address of the socket. Only works with accepted sockets!

Returns:
The remote address as a string
void OFTCPSocket::setKeepAlivesEnabled: ( BOOL  enable) [virtual]

Enable or disable keep alives for the connection.


The documentation for this class was generated from the following files:
 All Classes Functions Variables