OLSocket Class Reference
[Sockets]

An abstract base class for sockets. More...

#import <ObjectiveLib/Socket.h>

Inheritance diagram for OLSocket:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(BOOL) - allowsBroadcast
 Return whether this socket allows broadcasting.
(void) - close
 Close the socket.
(BOOL) - dontRoute
 Return whether routing is disabled.
(BOOL) - hasReusePortSupport
 Return whether the platform supports reusing ports.
(OLInStream *) - inStream
 Return the in stream associated with the socket.
(BOOL) - keepAlive
 Return whether "keep alive" is enabled.
(unsigned) - linger
 Return the number of seconds to linger.
(OLSocketAddress *) - localAddress
 Return the local address.
(BOOL) - outOfBandInline
 Return whether out-of-band data is received inline.
(OLOutStream *) - outStream
 Return the out stream associated with the socket.
(unsigned) - receiveBufferSize
 Return the size of the buffer for received data.
(unsigned) - receiveLowWaterMark
 Return the low-water mark for receiving data.
(unsigned) - receiveTimeOut
 Return the time out for receiving data.
(OLSocketAddress *) - remoteAddress
 Return the address of the socket's peer.
(BOOL) - reuseAddress
 Return whether reusing of addresses is enabled.
(BOOL) - reusePort
 Return whether this socket can reuse a port.
(unsigned) - sendBufferSize
 Return the size of the buffer for sent data.
(unsigned) - sendLowWaterMark
 Return the low-water mark for sending data.
(unsigned) - sendTimeOut
 Return the time out for sending data.
(void) - setAllowsBroadcast:
 Set whether this socket allows broadcasting.
(void) - setDontRoute:
 Set whether routing is disabled.
(void) - setKeepAlive:
 Set whether "keep alive" is enabled.
(void) - setLinger:
 Set the number of seconds to linger.
(void) - setOutOfBandInline:
 Set whether out-of-band data is received inline.
(void) - setReceiveBufferSize:
 Set the size of the buffer for receiving data.
(void) - setReceiveLowWaterMark:
 Set the low-water mark for receiving data.
(void) - setReceiveTimeOut:
 Set the time out for receiving data.
(void) - setReuseAddress:
 Set whether reusing of addresses is enabled.
(void) - setReusePort:
 Set whether this socket can reuse a port.
(void) - setSendBufferSize:
 Set the size of the buffer for sending data.
(void) - setSendLowWaterMark:
 Set the low-water mark for sending data.
(void) - setSendTimeOut:
 Set the time out for sending data.
(void) - shutdownRead
 Disallow incoming data to be received.
(void) - shutdownWrite
 Disallow outgoing data to be sent.
(int) - socketType
 Return the type of socket.
Initializers and Deallocators
(id) - free
 Finalize the socket and deallocate any allocated memory.

Protected Attributes

int fd
 The file descriptor associated with the socket.
OLInStreaminStream
 The socket's in stream.
OLOutStreamoutStream
 The socket's out stream.

Detailed Description

An abstract base class for sockets.

All the common functionality that all sockets possess is contained in OLSocket.


Member Function Documentation

- (BOOL) allowsBroadcast  

Return whether this socket allows broadcasting.

This message returns YES if the socket is capable of sending datagrams to a broadcast address.

See also:
- setAllowsBroadcast:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
YES if the socket allows broadcasting, NO otherwise

- (void) close  

Close the socket.

The socket will no longer be available for communication after receiving this message.

Exceptions:
OLSocketException if there is an error closing the socket

Reimplemented in OLUnixServerSocket.

- (BOOL) dontRoute  

Return whether routing is disabled.

If this message returns YES, then outgoing messages will bypass standard routing facilities.

See also:
- setDontRoute:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
YES if routing is disabled, NO otherwise

- (id) free  

Finalize the socket and deallocate any allocated memory.

- (BOOL) hasReusePortSupport  

Return whether the platform supports reusing ports.

This information can also be gleaned at compile time by checking whether OL_HAVE_SO_REUSEPORT is defined. If this message returns YES, then the messages reusePort and setReusePort: can meaningfully be used.

If this messages returns YES then more than one socket can be bound to the same port and all broadcast datagrams will be received by all sockets sharing the port.

See also:
- reusePort, - setReusePort:
Returns:
YES if the platform support reusing ports, NO otherwise

- (OLInStream*) inStream  

Return the in stream associated with the socket.

The in stream can be used to read data written by the socket connected to this one. The in stream returned is guaranteed to live as long as the socket does. If you attempt to retain and use the in stream after releasing the socket, you'll discover that it doesn't work.

See also:
outStream
Returns:
the socket's in stream

- (BOOL) keepAlive  

Return whether "keep alive" is enabled.

If this message returns YES, then the socket will periodically send messages to its peer in order to make sure the connection remains active.

See also:
- setKeepAlive:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
YES if "keep alive" is enabled, NO otherwise

- (unsigned) linger  

Return the number of seconds to linger.

If a linger interval is set, then the socket will block when close is called for the given number seconds while there is data remaining for the socket to transmit. If no linger interval is set, then this message return UINT_MAX. Also, if linger is set to zero, then close will not block, and pending data will be discarded. If linger is not enabled, then close will not block, but pending data will be sent anyway.

See also:
- setLinger:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
the number of seconds to linger or UINT_MAX if linger is not enabled

- (OLSocketAddress*) localAddress  

Return the local address.

The local address is the address to which this socket is bound.

See also:
- remoteAddress
Exceptions:
OLSocketException if the socket is not bound to a local address
Returns:
the local address

Reimplemented in OLUnixServerSocket.

- (BOOL) outOfBandInline  

Return whether out-of-band data is received inline.

When this message returns YES then all out-of-band data received on the socket will be mixed in with the normal data transmitted to the socket by its peer.

See also:
- setOutOfBandInline:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
YES if out-of-band data is received inline, NO otherwise

- (OLOutStream*) outStream  

Return the out stream associated with the socket.

The out stream can be used to write data that can be read by the socket's peer. The out stream returned is guaranteed to live as long as the socket does. If you attempt to retain and use the stream after releasing the socket, you'll discover that it doesn't work.

See also:
inStream
Returns:
the socket's out stream

- (unsigned) receiveBufferSize  

Return the size of the buffer for received data.

The system maintains a buffer for receiving data. This message tells you its size.

See also:
- setReceiveBufferSize:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
the size of the buffer for received data

- (unsigned) receiveLowWaterMark  

Return the low-water mark for receiving data.

The low-water mark refers to the minimum number of bytes for input operations.

See also:
- setReceiveLowWaterMark:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
the minimum number of bytes for input

- (unsigned) receiveTimeOut  

Return the time out for receiving data.

This value is the maximum amount of time in milliseconds that the socket will wait to receive requested data.

See also:
- setReceiveTimeOut:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
the number of milliseconds to wait to receive data

- (OLSocketAddress*) remoteAddress  

Return the address of the socket's peer.

The remote address is the one to which this socket is connected.

See also:
- localAddress
Exceptions:
OLSocketException if there is a problem retrieving the address
Returns:
the remote address

- (BOOL) reuseAddress  

Return whether reusing of addresses is enabled.

If this message returns YES, then this socket may be bound to an address that is in a time out state.

See also:
- setReuseAddress:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
YES if this socket can reuse an address, NO otherwise

- (BOOL) reusePort  

Return whether this socket can reuse a port.

If this message returns YES, then this socket can be bound to a port already in use by another socket for the purposes of receiving broadcast datagrams.

Note:
If the message hasReusePortSupport returns NO, then this message always returns NO.
See also:
- setReusePort:, - hasReusePortSupport
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
YES if this socket can reuse ports, NO otherwise

- (unsigned) sendBufferSize  

Return the size of the buffer for sent data.

The system maintains a buffer for sending data. This message tells you its size.

See also:
- setSendBufferSize:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
the size of the buffer for sent data

- (unsigned) sendLowWaterMark  

Return the low-water mark for sending data.

The low-water mark refers to the minimum number of bytes for output operations.

See also:
- setSendLowWaterMark:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
the minimum number of bytes for output

- (unsigned) sendTimeOut  

Return the time out for sending data.

This value is the maximum amount of time in milliseconds that the socket will wait to send data.

See also:
- setSendTimeOut:
Exceptions:
OLSocketException if there is an error retrieving the information
Returns:
the number of milliseconds to wait to send data

- (void) setAllowsBroadcast: (BOOL)  state  

Set whether this socket allows broadcasting.

Set state to YES if the socket should be capable of sending datagrams to a broadcast address.

See also:
- allowsBroadcast
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
state YES if the socket should allow broadcast, NO if not

- (void) setDontRoute: (BOOL)  state  

Set whether routing is disabled.

Set state to YES if outgoing messages should bypass standard routing facilities.

See also:
- dontRoute
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
state YES if routing should be disabled, NO if not

- (void) setKeepAlive: (BOOL)  state  

Set whether "keep alive" is enabled.

Set state to YES if the socket should periodically send messages to its peer in order to make sure the connection remains active.

See also:
- keepAlive
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
state YES if keep alive should be enabled, NO if not

- (void) setLinger: (unsigned)  value  

Set the number of seconds to linger.

If a linger interval is set, then the socket will block when close is called for the given number seconds while there is data remaining for the socket to transmit. If linger is set to zero, then close will not block, and pending data will be discarded. If linger is not enabled, then close will not block, but pending data will be sent anyway.

To disable lingering value should be set to UINT_MAX.

See also:
- linger
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
value the number of seconds to linger or UINT_MAX if lingering should be disabled

- (void) setOutOfBandInline: (BOOL)  state  

Set whether out-of-band data is received inline.

Set state to YES to make all out-of-band data received on the socket to be mixed in with the normal data transmitted to the socket by its peer.

See also:
- outOfBandInline
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
state YES if out-of-band data should be received inline, NO if not

- (void) setReceiveBufferSize: (unsigned)  size  

Set the size of the buffer for receiving data.

See also:
- receiveBufferSize
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
size the new size of the receive buffer

- (void) setReceiveLowWaterMark: (unsigned)  value  

Set the low-water mark for receiving data.

The low-water mark refers to the minimum number of bytes for input operations.

See also:
- receiveLowWaterMark
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
value the minimum number of bytes for input

- (void) setReceiveTimeOut: (unsigned)  value  

Set the time out for receiving data.

This value is the maximum amount of time in milliseconds that the socket will wait to receive requested data.

See also:
- receiveTimeOut
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
value the number of milliseconds to wait to receive data

- (void) setReuseAddress: (BOOL)  state  

Set whether reusing of addresses is enabled.

Set state to YES to enable this socket to be bound to an address that is in a time out state.

See also:
- reuseAddress
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
state YES if this socket should be able to reuse an address, NO if not

- (void) setReusePort: (BOOL)  state  

Set whether this socket can reuse a port.

Set state to YES so that this socket can be bound to a port already in use by another socket for the purposes of receiving broadcast datagrams.

Note:
If the message hasReusePortSupport returns NO, then this message has no effect.
See also:
- reusePort, - hasReusePortSupport
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
state YES if this socket should be able to reuse ports, NO if not

- (void) setSendBufferSize: (unsigned)  size  

Set the size of the buffer for sending data.

See also:
- sendBufferSize
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
size the new size of the send buffer

- (void) setSendLowWaterMark: (unsigned)  value  

Set the low-water mark for sending data.

The low-water mark refers to the minimum number of bytes for output operations.

See also:
- sendLowWaterMark
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
value the minimum number of bytes for output

- (void) setSendTimeOut: (unsigned)  value  

Set the time out for sending data.

This value is the maximum amount of time in milliseconds that the socket will wait to send data.

See also:
- sendTimeOut
Exceptions:
OLSocketException if there is an error setting the information
Parameters:
value the number of milliseconds to wait to send data

- (void) shutdownRead  

Disallow incoming data to be received.

After sending this message it will be impossible to read any more data from the socket.

Exceptions:
OLSocketException if there was a problem shutting down the socket

- (void) shutdownWrite  

Disallow outgoing data to be sent.

After sending this message it will be impossible to send any more data to the socket.

Exceptions:
OLSocketException if there was a problem shutting down the socket

- (int) socketType  

Return the type of socket.

The value returned is a platform-dependent number that represents the type of the socket. This number will correspond to a defined value such as SOCK_STREAM or SOCK_DGRAM.

Exceptions:
OLSocketException if there was a problem retrieving the information
Returns:
the type of the socket


Member Data Documentation

- (int) fd [protected]

The file descriptor associated with the socket.

- (OLInStream*) inStream [protected]

The socket's in stream.

- (OLOutStream*) outStream [protected]

The socket's out stream.


The documentation for this class was generated from the following file:
ObjectiveLibGenerated Sun Apr 22 15:19:04 2007, © 2004-2007 Will Mason
SourceForge.net Logo