ObjFW
|
A class which provides functions to create and use TCP sockets. More...
#import <OFTCPSocket.h>
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. |
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.
- (OFTCPSocket *) accept |
Accept an incoming connection.
- (uint16_t) bindToHost: | (OFString*) | host | |
port: | (uint16_t) | port | |
Bind the socket on the specified port and host.
host | The host to bind to. Use "0.0.0.0" for IPv4 or @"::" for IPv6 to bind to all. |
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. |
- (void) connectToHost: | (OFString*) | host | |
port: | (uint16_t) | port | |
Connect the OFTCPSocket to the specified destination.
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) listenWithBackLog: | (int) | backLog |
Listen on the socket.
backlog | Maximum length for the queue of pending connections. |
- (OFString *) remoteAddress |
Returns the remote address of the socket.
Only works with accepted sockets!
- (void) setKeepAlivesEnabled: | (BOOL) | enable |
Enable or disable keep alives for the connection.
enable | Whether 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.
host | The 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.
host | The 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.
port | The 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.
port | The port to use on the SOCKS5 proxy |
+ (OFString*) SOCKS5Host |
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.
+ (uint16_t) SOCKS5Port |
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.