FMIceLinkTcpSocket Class Reference

Inherits from FMIceLinkStreamSocket : FMIceLinkManagedSocket : NSObject
Conforms to FMIceLinkAsyncSocketDelegate
Declared in FMIceLinkTcpSocket.h
FMIceLinkTcpSocket.m

– server

Gets a value indicating whether the socket can accept incoming connections.
- (bool)server

Discussion

Gets a value indicating whether the socket can accept incoming connections.

Declared In

FMIceLinkStreamSocket.h

– secure

Gets a value indicating whether the socket is secure.
- (bool)secure

Discussion

Gets a value indicating whether the socket is secure.

Declared In

FMIceLinkStreamSocket.h

– ipv6

Gets a value indicating whether the socket supports IPv6.
- (bool)ipv6

Discussion

Gets a value indicating whether the socket supports IPv6.

Declared In

FMIceLinkManagedSocket.h

– isClosed

Gets a value indicating whether this instance is closed.
- (bool)isClosed

Discussion

Gets a value indicating whether this instance is closed.

Declared In

FMIceLinkManagedSocket.h

– localIPAddress

Gets the local IP address.
- (NSString *)localIPAddress

Discussion

Gets the local IP address.

Declared In

FMIceLinkManagedSocket.h

– localPort

Gets the local port.
- (int)localPort

Discussion

Gets the local port.

Declared In

FMIceLinkManagedSocket.h

– remoteIPAddress

Gets the remote IP address.
- (NSString *)remoteIPAddress

Discussion

Gets the remote IP address.

Declared In

FMIceLinkStreamSocket.h

– remotePort

Gets the remote port.
- (int)remotePort

Discussion

Gets the remote port.

Declared In

FMIceLinkStreamSocket.h

– bindWithIPAddress:port:addressInUse:

Binds the socket to a local endpoint.
- (bool)bindWithIPAddress:(NSString *)ipAddress port:(int)port addressInUse:(bool *)addressInUse

Parameters

ipAddress

The local IP address.

port

The local port.

addressInUse

Indicates that access to the address is forbidden or in use.

Discussion

Binds the socket to a local endpoint.

Declared In

FMIceLinkManagedSocket.h

– acceptAsyncWithOnSuccess:onFailure:onSocket:

Accepts a new socket asynchronously.
- (void)acceptAsyncWithOnSuccess:(FMIceLinkAction0 *)onSuccess onFailure:(FMIceLinkAction1 *)onFailure onSocket:(FMIceLinkAction1 *)onSocket

Parameters

onSuccess

The callback to invoke on success.

onFailure

The callback to invoke on failure.

onSocket

The callback to invoke when a socket is ready.

Discussion

Accepts a new socket asynchronously.

Declared In

FMIceLinkStreamSocket.h

– socket:didAcceptNewSocket:

Called when a socket accepts a connection. Another socket is automatically spawned to handle it.

- (void)socket:(FMIceLinkAsyncSocket *)sock didAcceptNewSocket:(FMIceLinkAsyncSocket *)newSocket

Discussion

Called when a socket accepts a connection. Another socket is automatically spawned to handle it.

You must retain the newSocket if you wish to handle the connection. Otherwise the newSocket instance will be released and the spawned connection will be closed.

By default the new socket will have the same delegate and delegateQueue. You may, of course, change this at any time.

Declared In

FMIceLinkAsyncSocket.h

– connectAsyncWithHostname:ipAddress:port:timeout:onSuccess:onFailure:

Connects the socket asynchronously.
- (void)connectAsyncWithHostname:(NSString *)hostname ipAddress:(NSString *)ipAddress port:(int)port timeout:(int)timeout onSuccess:(FMIceLinkAction0 *)onSuccess onFailure:(FMIceLinkAction2 *)onFailure

Parameters

hostname

The remote hostname.

ipAddress

The remote IP address.

port

The remote port.

timeout

The timeout (in ms).

onSuccess

The callback to invoke on success.

onFailure

The callback to invoke on failure.

Discussion

Connects the socket asynchronously.

Declared In

FMIceLinkStreamSocket.h

– socket:didConnectToHost:port:

Called when a socket connects and is ready for reading and writing. The host parameter will be an IP address, not a DNS name.

- (void)socket:(FMIceLinkAsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port

Discussion

Called when a socket connects and is ready for reading and writing. The host parameter will be an IP address, not a DNS name.

Declared In

FMIceLinkAsyncSocket.h

– socketDidSecure:

Called after the socket has successfully completed SSL/TLS negotiation. This method is not called unless you use the provided startTLS method.

- (void)socketDidSecure:(FMIceLinkAsyncSocket *)sock

Discussion

Called after the socket has successfully completed SSL/TLS negotiation. This method is not called unless you use the provided startTLS method.

If a SSL/TLS negotiation fails (invalid certificate, etc) then the socket will immediately close, and the socketDidDisconnect:withError: delegate method will be called with the specific SSL error code.

Declared In

FMIceLinkAsyncSocket.h

– receiveAsyncWithTimeout:

Receives data asynchronously.
- (void)receiveAsyncWithTimeout:(int)timeout

Parameters

timeout

The timeout (in ms).

Discussion

Receives data asynchronously.

Declared In

FMIceLinkStreamSocket.h

– socket:didReadData:withTag:

Called when a socket has completed reading the requested data into memory. Not called if there is an error.

- (void)socket:(FMIceLinkAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag

Discussion

Called when a socket has completed reading the requested data into memory. Not called if there is an error.

Declared In

FMIceLinkAsyncSocket.h

– sendWithBuffer:

Sends data synchronously.
- (bool)sendWithBuffer:(FMIceLinkDataBuffer *)buffer

Parameters

buffer

The buffer.

Discussion

Sends data synchronously.

Declared In

FMIceLinkStreamSocket.h

– sendAsyncWithBuffer:timeout:onSuccess:onFailure:

Sends data asynchronously.
- (void)sendAsyncWithBuffer:(FMIceLinkDataBuffer *)buffer timeout:(int)timeout onSuccess:(FMIceLinkAction0 *)onSuccess onFailure:(FMIceLinkAction2 *)onFailure

Parameters

buffer

The buffer.

timeout

The timeout (in ms).

onSuccess

The callback to invoke on success.

onFailure

The callback to invoke on failure.

Discussion

Sends data asynchronously.

Declared In

FMIceLinkStreamSocket.h

– socket:didWriteDataWithTag:

Called when a socket has completed writing the requested data. Not called if there is an error.

- (void)socket:(FMIceLinkAsyncSocket *)sock didWriteDataWithTag:(long)tag

Discussion

Called when a socket has completed writing the requested data. Not called if there is an error.

Declared In

FMIceLinkAsyncSocket.h

– socketDidDisconnect:withError:

Called when a socket disconnects with or without error.

- (void)socketDidDisconnect:(FMIceLinkAsyncSocket *)sock withError:(NSError *)err

Discussion

Called when a socket disconnects with or without error.

If you call the disconnect method, and the socket wasn’t already disconnected, then an invocation of this delegate method will be enqueued on the delegateQueue before the disconnect method returns.

Note: If the FMIceLinkAsyncSocket instance is deallocated while it is still connected, and the delegate is not also deallocated, then this method will be invoked, but the sock parameter will be nil. (It must necessarily be nil since it is no longer available.) This is a generally rare, but is possible if one writes code like this:

asyncSocket = nil; // I’m implicitly disconnecting the socket

In this case it may preferrable to nil the delegate beforehand, like this:

asyncSocket.delegate = nil; // Don’t invoke my delegate method asyncSocket = nil; // I’m implicitly disconnecting the socket

Of course, this depends on how your state machine is configured.

Declared In

FMIceLinkAsyncSocket.h

– close

Closes the socket.
- (void)close

Discussion

Closes the socket.

Declared In

FMIceLinkManagedSocket.h