ObjFW
Public Member Functions | Static Public Member Functions
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 <OFCopying> <OFObject>

List of all members.

Public Member Functions

(void) - setSOCKS5Host:
 Sets the host to use as a SOCKS5 proxy.
(OFString *) - SOCKS5Host
 Returns the host to use as a SOCKS5 proxy.
(void) - setSOCKS5Port:
 Sets the port to use on the SOCKS5 proxy.
(uint16_t) - SOCKS5Port
 Returns the port to use on the SOCKS5 proxy.
(void) - connectToHost:port:
 Connect the OFTCPSocket to the specified destination.
(uint16_t) - bindToHost:port:
 Bind the socket on the specified port and host.
(void) - listenWithBackLog:
 Listen on the socket.
(void) - listen
 Listen on the socket.
(OFTCPSocket *) - accept
 Accept an incoming connection.
(void) - setKeepAlivesEnabled:
 Enable or disable keep alives for the connection.
(OFString *) - remoteAddress
 Returns the remote address of the socket.
(BOOL) - isListening
 Returns whether the socket is a listening socket.

Static Public Member Functions

(void) + setSOCKS5Host:
 Sets the global SOCKS5 proxy host to use when creating a new socket.
(OFString *) + SOCKS5Host
 Returns the host to use as a SOCKS5 proxy when creating a new socket.
(void) + setSOCKS5Port:
 Sets the global SOCKS5 proxy port to use when creating a new socket.
(uint16_t) + SOCKS5Port
 Returns the port to use as a SOCKS5 proxy when creating a new socket.

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) bindToHost: (OFString*)  host
port: (uint16_t)  port 

Bind the socket on the specified port and host.

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

Connect the OFTCPSocket to the specified destination.

Parameters:
hostThe host to connect to
portThe port on the host to connect to
- (BOOL) isListening

Returns whether the socket is a listening socket.

Returns:
Whether the socket is a listening socket
- (void) listenWithBackLog: (int)  backLog

Listen on the socket.

Parameters:
backlogMaximum 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.

Parameters:
enableWhether to enable or disable keep alives for the connection
+ (void) setSOCKS5Host: (OFString*)  host

Sets the global SOCKS5 proxy host to use when creating a new socket.

Parameters:
hostThe host to use as a SOCKS5 proxy when creating a new socket
- (void) setSOCKS5Host: (OFString *)  host

Sets the host to use as a SOCKS5 proxy.

Parameters:
hostThe host to use as a SOCKS5 proxy
+ (void) setSOCKS5Port: (uint16_t)  port

Sets the global SOCKS5 proxy port to use when creating a new socket.

Parameters:
portThe port to use as a SOCKS5 proxy when creating a new socket
- (void) setSOCKS5Port: (uint16_t)  port

Sets the port to use on the SOCKS5 proxy.

The default port is 1080.

Parameters:
portThe port to use on the SOCKS5 proxy
+ (OFString*) SOCKS5Host

Returns the host to use as a SOCKS5 proxy when creating a new socket.

Returns:
The host to use as a SOCKS5 proxy when creating a new socket
- (OFString*) SOCKS5Host

Returns the host to use as a SOCKS5 proxy.

Returns:
The host to use as a SOCKS5 proxy
+ (uint16_t) SOCKS5Port

Returns the port to use as a SOCKS5 proxy when creating a new socket.

Returns:
The port to use as a SOCKS5 proxy when creating a new socket
- (uint16_t) SOCKS5Port

Returns the port to use on the SOCKS5 proxy.

Returns:
The port to use on the SOCKS5 proxy

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