Public Member Functions | Protected Attributes

OFTCPSocket Class Reference

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

#import <OFTCPSocket.h>

Inheritance diagram for OFTCPSocket:
OFStreamSocket OFStream OFObject <OFObject>

List of all members.

Public Member Functions

(void) - connectToHost:onPort:
(uint16_t) - bindToPort:onHost:
(void) - listenWithBackLog:
(void) - listen
(OFTCPSocket *) - accept
(void) - setKeepAlivesEnabled:
(OFString *) - remoteAddress
(BOOL) - isListening

Protected Attributes

BOOL isListening
struct sockaddr * 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 *) accept  

Accept an incoming connection.

Returns:
An autoreleased OFTCPSocket for the accepted connection.
- (uint16_t) bindToPort: (uint16_t)  port
onHost: (OFString*)  host 

Bind the socket on the specified port and host.

Parameters:
port The port to bind to. If the port is 0, an unused port will be chosen, which can be obtained using the return value.
host The 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) connectToHost: (OFString*)  host
onPort: (uint16_t)  port 

Connect the OFTCPSocket to the specified destination.

Parameters:
host The host to connect to
port The port on the host to connect to
- (BOOL) isListening  
Returns:
Whether the socket is a listening socket
- (void) listen  

Listen on the socket.

- (void) listenWithBackLog: (int)  backlog  

Listen on the socket.

Parameters:
backlog Maximum length for the queue of pending connections.
- (OFString *) remoteAddress  

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

Returns:
The remote address as a string
- (void) setKeepAlivesEnabled: (BOOL)  enable  

Enable or disable keep alives for the connection.


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