CrystalSpace

Public API Reference

CS::Network::Socket::iSocket Struct Reference

A socket connection obtained from iSocketManager. More...

#include <inetwork/socket.h>

Inheritance diagram for CS::Network::Socket::iSocket:

List of all members.

Public Member Functions

virtual csPtr< iSocketAccept (csRef< iAddress > *client=nullptr)=0
 Accept a currently pending connection while listening from them on a bound address.
virtual bool Bind (iAddress const *address)=0
 Bind this socket to a local address.
virtual bool Connect (iAddress const *client)=0
 Connects to the peer specified by the passed iAddress.
virtual Family GetFamily () const =0
 Returns the address family this socket can work with.
virtual char const * GetLastError () const =0
 Obtain a textual description of the last error that occured.
virtual Protocol GetProtocol () const =0
 Returns the transport protocol this socket is using.
virtual bool IsConnected () const =0
 Check whether this socket is associated with a peer.
virtual bool IsReady () const =0
 Check whether this socket is ready to transmit data.
virtual bool Listen (int queueSize)=0
 Start to listen for incoming connections on the the bound address.
virtual size_t Receive (char *buffer, size_t size, csRef< iAddress > *client=nullptr)=0
 Receive data from the peer this socket is connected to if a connection was established.
virtual size_t Send (char const *buffer, size_t size, iAddress *client=nullptr)=0
 Sends at most size bytes of data read from buffer to a peer.

Detailed Description

A socket connection obtained from iSocketManager.

Definition at line 70 of file socket.h.


Member Function Documentation

virtual csPtr<iSocket> CS::Network::Socket::iSocket::Accept ( csRef< iAddress > *  client = nullptr  )  [pure virtual]

Accept a currently pending connection while listening from them on a bound address.

This will block until a connection is ready to be accepted if there's non currently waiting. In order to check whether there's a connection pending in the queue use iSocketManager::Select and check whether this socket is ready to be read.

If a pointer to a placeholder for an iAddress is passed it'll hold the address of the peer that connected on success.

Returns a socket for the established connection on success, else nullptr is returned.

virtual bool CS::Network::Socket::iSocket::Bind ( iAddress const *  address  )  [pure virtual]

Bind this socket to a local address.

This is required before any communication can can occur for UDP sockets and is also required for TCP servers before any listening can occur.

virtual bool CS::Network::Socket::iSocket::Connect ( iAddress const *  client  )  [pure virtual]

Connects to the peer specified by the passed iAddress.

This is required for TCP sockets before any data can be transmitted.

For UDP sockets connecting is optional and specifies that data may only be sent to and received from the specified peer.

Returns true if a connection could be established and false if an error occured.

virtual Family CS::Network::Socket::iSocket::GetFamily (  )  const [pure virtual]

Returns the address family this socket can work with.

virtual char const* CS::Network::Socket::iSocket::GetLastError (  )  const [pure virtual]

Obtain a textual description of the last error that occured.

Note that due to platform restrictions this error may not have necessarily occured due to errors related to this socket.

virtual Protocol CS::Network::Socket::iSocket::GetProtocol (  )  const [pure virtual]

Returns the transport protocol this socket is using.

virtual bool CS::Network::Socket::iSocket::IsConnected (  )  const [pure virtual]

Check whether this socket is associated with a peer.

Returns true if it is, false otherwise.

virtual bool CS::Network::Socket::iSocket::IsReady (  )  const [pure virtual]

Check whether this socket is ready to transmit data.

Returns true if it is, false otherwise.

virtual bool CS::Network::Socket::iSocket::Listen ( int  queueSize  )  [pure virtual]

Start to listen for incoming connections on the the bound address.

This is required before any connections can be accepted for TCP servers.

The queue size specifies how many incoming connections that haven't been accepted, yet, may be waiting in a queue without being rejected.

virtual size_t CS::Network::Socket::iSocket::Receive ( char *  buffer,
size_t  size,
csRef< iAddress > *  client = nullptr 
) [pure virtual]

Receive data from the peer this socket is connected to if a connection was established.

If no connection was established and this is a UDP socket data from any peer will be read.

The read data will be written to the buffer passed and at most size bytes will be read.

If a pointer to a placeholder for an iAddress was passed this placeholder will be filled with information about the peer from which the data was received.

Returns the number of bytes actually received into the buffer or size_t(-1) if an error occured.

virtual size_t CS::Network::Socket::iSocket::Send ( char const *  buffer,
size_t  size,
iAddress client = nullptr 
) [pure virtual]

Sends at most size bytes of data read from buffer to a peer.

The peer the data is sent to is the one this socket is connected to if this socket is connect and otherwise the one specified by the passed address. It is an error to specify a peer if the socket is connected or is a TCP socket and to not pass a peer if the socket is not connected and a UDP socket.

On success the actual numeber of bytes sent will be returned which will not exceed size. Otherwise size_t(-1) is returned to indicate an error.


The documentation for this struct was generated from the following file:

Generated for Crystal Space 2.1 by doxygen 1.6.1