A class which provides functions to create and use TCP sockets. More...
#import <OFTCPSocket.h>
Instance Methods | |
(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. | |
(void) | - asyncConnectToHost:port:target:selector: |
Asyncronously 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) | - asyncAcceptWithTarget:selector: |
Asyncronously ccept 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. | |
Class Methods | |
(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. | |
Class Methods inherited from OFStreamSocket | |
(instancetype) | + socket |
Returns a new, autoreleased OFTCPSocket. | |
Additional Inherited Members | |
Public Attributes inherited from OFObject | |
Class | isa |
The class of the object. | |
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.
- (void) asyncAcceptWithTarget: | (id) | target | |
selector: | (SEL) | selector | |
Asyncronously ccept an incoming connection.
target | The target on which to execute the selector when a new connection has been accepted. The method returns whether the next incoming connection should be accepted by the specified block as well. |
selector | The selector to call on the target. The signature must be BOOL (OFTCPSocket *socket, OFTCPSocket *acceptedSocket, OFException *exception). |
- (void) asyncConnectToHost: | (OFString*) | host | |
port: | (uint16_t) | port | |
target: | (id) | target | |
selector: | (SEL) | selector | |
Asyncronously connect the OFTCPSocket to the specified destination.
host | The host to connect to |
port | The port on the host to connect to |
target | The target on which to call the selector once the connection has been established |
selector | The selector to call on the target. The signature must be void (OFTCPSocket *socket, OFException *exception). |
- (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.