EDIPSocket


Inherits From:
EDSocket
Declared In:
EDIPSocket.h


Class Description

This class provides methods for basic IP funtionality: binding to a port, connecting to an address, setting popular socket options, etc. It is not meant to be instantiated, though. This is left to its two sublasses EDTCPSocket and EDUDPSocket.

Note that some (IP) socket related functionality is implemented in a category on NSFileHandle.


Global Variables

Synopsis:

NSString *EDSocketTemporaryConnectionFailureException;

Description:

Name of an exception which occurs when the connection to a remote port fails due to a timeout.

Synopsis:

NSString *EDSocketConnectionRefusedException;

Description:

Name of an exception which occurs when the connection to a remote port is refused.


Instance Variables

struct _EDIPSFlags flags;

flagsAll instance variables are private.


Method Types

Setting socket options
- setAllowsTransmittingBroadcastMessages:
- setAllowsAddressReuse:
- setAllowsPortReuse:
- setSendTimeout:
- setReceiveTimeout:
Set local endpoint
- setLocalPort:
- setLocalPort:andAddress:
Set remote endpoint
- connectToHost:port:
- connectToAddress:port:
Status
- isConnected

Instance Methods

connectToAddress:port:

- (void)connectToAddress:(NSString *)addressString port:(unsigned short)port

Attempts to connect the remote endpoint of the socket to port on the host with the IP address described by addressString; the latter being in the "typical" dotted numerical notation.


connectToHost:port:

- (void)connectToHost:(NSHost *)host port:(unsigned short)port

Attempts to connect the remote endpoint of the socket to port on host.


isConnected

- (BOOL)isConnected

Returns YES if the socket allows communication, either in both directions or only sending or receiving; the latter resulting from shutdownInput or shutdownOutput invocations. (These are implemented in a category on NSFileHandle.) It only returns NO if the socket is completely disconnected.


setAllowsAddressReuse:

- (void)setAllowsAddressReuse:(BOOL)flag

Controls how quickly an address/port combination can be re-used. With this option set a socket can be connected to a port that is still in TIME_WAIT state which is useful if your server has been shut down, and then restarted right away while sockets are still active on its port. You should be aware that if any unexpected data comes in, it may confuse your server, but while this is possible, it is not likely. This corresponds to SO_REUSEADDR.


setAllowsPortReuse:

- (void)setAllowsPortReuse:(BOOL)flag

Controls whether the address/port combination can be shared by multiple sockets. Note that all sockets sharing the address/port must have this option set for it to work. This corresponds SO_REUSEPORT and is currently only implemented on Apple platforms even though other BSD and BSD-derived systems should support it. Note that for multicast addresses this is considered synonymous to SO_REUSEADDR ("TCP/IP Illustrated, Volume 2", p. 731.) So, for portability of multicasting applications you should use setAllowsAddressReuse: instead.


setAllowsTransmittingBroadcastMessages:

- (void)setAllowsTransmittingBroadcastMessages:(BOOL)flag

Controls whether broadcast messages are allowed. This corresponds to SO_BROADCAST.


setLocalPort:

- (void)setLocalPort:(unsigned short)port

Binds the local endpoint of the socket to aPort on all local IP addresses (interfaces).


setLocalPort:andAddress:

- (void)setLocalPort:(unsigned short)port andAddress:(NSString *)addressString

Binds the local endpoint of the socket to aPort on the local IP address described by addressString; the latter being in the "typical" dotted numerical notation.


setReceiveTimeout:

- (void)setReceiveTimeout:(NSTimeInterval)aTimeoutVal

Sets the timeout for receive (read) operations to aTimeoutVal. This corresponds to SO_RCVTIMEO.


setSendTimeout:

- (void)setSendTimeout:(NSTimeInterval)aTimeoutVal

Sets the timeout for send (write) operations to aTimeoutVal. This corresponds to SO_SNDTIMEO.


Version 2.0 Copyright ©2002. All Rights Reserved.