- Inherits from:
- Object
- Declared in:
- DSocket.h
Object
|
+---DSocket
Class Description
The DSocket class implements a number of methods for using network sockets.
- Last modified:
- 23-Jul-2006 (DSocket.h)
Instance Variables
- private int _socket
- the socket
- private id <DSocketAddressable> _address
- the address (reference)
- private int _family
- the socket family (DSA_AF_INET,DSA_AF_UNIX)
- private int _type
- the socket type
- private int _protocol
- the socket protocol
- private BOOL _blocking
- is the socket blocking ?
- private int _errno
- the last error
- Constructors
- - (DSocket *) init
- Initialise the socket
- Returns:
- the object
- - (DSocket *) init :(int) family :(int) type :(int) protocol
- Initialise the socket with a family, type and protocol
- Parameters:
- family - the socket family (DSA_AF_INET, DSA_AF_UNIX)
type - the socket type (DSK_STREAM, DSK_DGRAM)
protocol - the protocol
- Returns:
- the object
- - (DSocket *) init :(int) fileno :(id <DSocketAddressable>) address :(int) type :(int) protocol
- Initialise the socket with an already opened socket file descriptor
- Parameters:
- fileno - the opened socket file descriptor
address - the address for the socket file descriptor
type - the socket type (DSK_STREAM, DSK_DGRAM)
protocol - the protocol
- Returns:
- the object
- Copy related methods
- - shallowCopy
- Do a shallow copy of the object (not implemented)
- Returns:
- the object
- Deconstructor
- - free
- Free the socket object
- Returns:
- the object
- Class methods
- + (int) protocol :(const char *) name
- Determine the protocol for a protocol name
- Parameters:
- name - the name of the protocol
- Returns:
- the protocol number (or -1 if not found)
- Member methods
- - (int) error
- Get the last error
- Returns:
- the last error number
- - (int) family
- Get the socket family
- Returns:
- the family (DSA_AF_INET, DSA_AF_UNIX, DSA_AF_INET6)
- - (int) fileno
- Get the sockets file descriptor
- Returns:
- the file descriptor (or -1)
- - (int) type
- Get the socket type
- Returns:
- the type (DSK_STREAM, DSK_DGRAM)
- Socket option methods
- - (BOOL) blocking
- Get the socket blocking state
- Returns:
- is the socket blocking ?
- - (BOOL) blocking :(BOOL) block
- Set the socket blocking
- Parameters:
- block - should the socket be blocking ?
- Returns:
- success
- - (BOOL) getSocketOption :(int) level :(int) optname :(void *) optval :(int) optsize
- Get a socket option
- Parameters:
- level - the level for the socket option (e.g. SOL_SOCKET)
optname - the name for the socket option
optval - the pointer to the option value
optsize - the size of the option value
- Returns:
- success
- - (BOOL) keepAlive
- Get the keep alive socket option
- Returns:
- the keep alive setting
- - (BOOL) keepAlive :(BOOL) keep
- Set the keep alive socket option
- Parameters:
- keep - should the connnection keep alive ?
- Returns:
- success
- - (unsigned) linger
- Get the linger time out value
- Returns:
- the linger time out value (or 0 for off)
- - (BOOL) linger :(unsigned) secs
- Set the linger time out value
- Parameters:
- secs - the number of seconds for linger (or 0 for off)
- Returns:
- success
- - (int) receiveBufferSize
- Get the receive buffer size socket option
- Returns:
- the size
- - (BOOL) receiveBufferSize :(int) size
- Set the receive buffer size socket option
- Parameters:
- size - the size for the receive buffer
- Returns:
- success
- - (BOOL) reuseAddr
- Get the reuse address socket option
- Returns:
- can the address be reused ?
- - (BOOL) reuseAddr :(BOOL) reuse
- Set the reuse address socket option
- Parameters:
- reuse - can the address be reused ?
- Returns:
- success
- - (int) sendBufferSize
- Get the send buffer size socket option
- Returns:
- the size
- - (BOOL) sendBufferSize :(int) size
- Set the send buffer size socket option
- Parameters:
- size - the size for the send buffer
- Returns:
- success
- - (BOOL) setSocketOption :(int) level :(int) optname :(void *) optval :(int) optsize
- Set a socket option
- Parameters:
- level - the level for the socket option (e.g. SOL_SOCKET)
optname - the name for the socket option
optval - the pointer to the option value
optsize - the size of the option value
- Returns:
- success
- Connection methods
- - (DSocket *) accept
- Accept a connection (server only)
- Returns:
- the (new) socket object for the connection (or nil for error)
- - (BOOL) bind :(id <DSocketAddressable>) address
- Bind the socket to the address (inet:server only, unix:both)
- Parameters:
- address - the address to bind to
- Returns:
- success
- - (BOOL) close
- Close a socket
- Returns:
- success
- - (BOOL) connect :(id <DSocketAddressable>) address
- Connect a client to a server
- Parameters:
- address - the address of the server
- Returns:
- success
- - (BOOL) listen :(int) backlog
- Listen for incoming connnections by a server
- Parameters:
- backlog - the number of pending connection before refuse
- Returns:
- success
- - (BOOL) open :(int) family :(int) type :(int) protocol
- Open a socket
- Parameters:
- family - the socket family (DSA_AF_INET, DSA_AF_UNIX)
type - the socket type (DSK_STREAM, DSK_DGRAM)
protocol - the protocol (see [protocol :name])
- Returns:
- success
- - (BOOL) shutdown :(int) what
- Shutdown the connection
- Parameters:
- what - what part of the connection must be shutdown (DSK_SHUT_RD,DSK_SHUT_WR,DSK_SHUT_RDWR)
- Returns:
- success
- Data transfer methods
- - (DData *) recv :(int) length :(int) flags
- Receive data (TCP)
- Parameters:
- length - the length of the data to be received
flags - the receive flags (DSK_MSG.. or 0)
- Returns:
- a new DData object (or nil)
- - (DData *) recvfrom :(id <DSocketAddressable>) address :(int) length :(int) flags
- Receive data (UDP)
- Parameters:
- address - the destination for the peer address
length - the length of the data to be received
flags - the receive flags (DSK_MSG.. or 0)
- Returns:
- a new DData object (or nil)
- - (int) send :(void *) data :(int) length :(int) flags
- Send data (TCP)
- Parameters:
- data - the data to be sent
length - the length of the data
flags - the message flags (DSK_MSG.. or 0)
- Returns:
- the number of bytes sent (or -1 for error)
- - (int) sendto :(id <DSocketAddressable>) address :(void *) data :(int) length :(int) flags
- Send data (UDP)
- Parameters:
- address - the address to send to
data - the data to be sent
length - the length of the data
flags - the message flags (DSK_MSG.. or 0)
- Returns:
- the number of bytes sent (or -1 for error)
- Text transfer methods
- - (int) recv :(DText *) dest :(int) length :(int) flags
- Receive text (TCP)
- Parameters:
- dest - the destination text object
length - the length of the data to be received
flags - the receive flags (DSK_MSG.. or 0)
- Returns:
- the number of characters received (or -1 for error)
- - (int) recvfrom :(DText *) dest :(id <DSocketAddressable>) address :(int) length :(int) flags
- Receive text (UDP)
- Parameters:
- dest - the destination text object
address - the destination for the peer address
length - the length of the data to be received
flags - the receive flags (DSK_MSG.. or 0)
- Returns:
- the number of bytes received (or -1)
- - (int) send :(const char *) cstring :(int) flags
- Send text (TCP)
- Parameters:
- cstring - the c-string to be sent
flags - the message flags (DSK_MSG.. or 0)
- Returns:
- the number of bytes sent (or -1 for error)
- - (int) sendto :(id <DSocketAddressable>) address :(const char *) cstring :(int) flags
- Send text (UDP)
- Parameters:
- address - the address to send to
cstring - the cstring to be sent
flags - the message flags (DSK_MSG.. or 0)
- Returns:
- the number of bytes sent (or -1 for error)
generated 25-Jul-2006 by ObjcDoc 3.0.0