CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

iNetworkSocket2 Struct Reference

A network socket. More...

#include <socket2.h>

Inheritance diagram for iNetworkSocket2:

iBase List of all members.

Public Methods

virtual bool IsConnected () const=0
 Returns true if the connection is TCP and the socket is connected. More...

virtual int LastError () const=0
 Returns last driver error (see CS_NET_SOCKET_FOO in inetwork/driver2.h). More...

virtual int SetSocketBlock (bool block)=0
 Sets the socket blocking operation if block is true, or unsets the blocking operation if block is false. More...

virtual int SetSocketReuse (bool reuse)=0
 Sets the reuse option on a server socket if reuse is true, otherwise the reuse option is unset. More...

virtual int SetSocketBroadcast (bool broadcast)=0
 Sets the broadcast option on socket if broadcast is true, otherwise the broadcast option is unset. More...

virtual int SetBroadcastOptions (int port, const char *addr=0)=0
 Sets the broadcast port and address (0 means broadcast to all). More...

virtual int Connect (char const *host, int port)=0
 Connect to the hostname host on port port. More...

virtual int Send (char const *buff, size_t size)=0
 Send size bytes of buff to remote connection. More...

virtual int Recv (char *buff, size_t size)=0
 Read size of bytes from connection into buff. More...

virtual int Close ()=0
 Closes the network socket. The socket is unusible after this call. More...

virtual int Disconnect ()=0
 Disconnects the socket connection. Then calls closes the socket. More...

virtual int WaitForConnection (int source, int port, int queue)=0
 Binds to the interface source on port port. More...

virtual iNetworkSocket2 * Accept ()=0
 Returns a NetworkSocket2 instance for the new connection. More...

virtual int ReadLine (char *buff, size_t size)=0
 Performs a buffered read on either TCP or UDP connections until size bytes is reached or '\r' or '\0' is received. More...

virtual char const * RemoteName () const=0
 Returns a string containing either the IP or hostname of the remote connection. More...


Detailed Description

A network socket.

Network sockets are created via invocations of iNetworkDriver2::CreateSocket().

Definition at line 35 of file socket2.h.


Member Function Documentation

virtual iNetworkSocket2* iNetworkSocket2::Accept   [pure virtual]
 

Returns a NetworkSocket2 instance for the new connection.

Returns 0 on error. Use LastError() for the actual error.

virtual int iNetworkSocket2::Close   [pure virtual]
 

Closes the network socket. The socket is unusible after this call.

virtual int iNetworkSocket2::Connect char const *    host,
int    port
[pure virtual]
 

Connect to the hostname host on port port.

Returns CS_NET_SOCKET_NOERROR if there is no error.

virtual int iNetworkSocket2::Disconnect   [pure virtual]
 

Disconnects the socket connection. Then calls closes the socket.

virtual bool iNetworkSocket2::IsConnected   const [pure virtual]
 

Returns true if the connection is TCP and the socket is connected.

Returns false if the connection is TCP and the socket is not connected, or the connection is UDP.

virtual int iNetworkSocket2::LastError   const [pure virtual]
 

Returns last driver error (see CS_NET_SOCKET_FOO in inetwork/driver2.h).

virtual int iNetworkSocket2::ReadLine char *    buff,
size_t    size
[pure virtual]
 

Performs a buffered read on either TCP or UDP connections until size bytes is reached or '\r' or '\0' is received.

Returns number of bytes read into buff when complete. Returns 0 when line is incomplete. Returns -1 upon error. Use LastError() for the actual error.

virtual int iNetworkSocket2::Recv char *    buff,
size_t    size
[pure virtual]
 

Read size of bytes from connection into buff.

Returns number of bytes stored in buff or -1 on error. This function doesn't block on UDP connections. If connection is UDP then this function returns CS_NET_SOCKET_NODATA if nothing was read. Use LastError() for the actual error.

virtual char const* iNetworkSocket2::RemoteName   const [pure virtual]
 

Returns a string containing either the IP or hostname of the remote connection.

virtual int iNetworkSocket2::Send char const *    buff,
size_t    size
[pure virtual]
 

Send size bytes of buff to remote connection.

Returns number of bytes sent or -1 on error. Use LastError() for the actual error.

virtual int iNetworkSocket2::SetBroadcastOptions int    port,
const char *    addr = 0
[pure virtual]
 

Sets the broadcast port and address (0 means broadcast to all).

Returns CS_NET_SOCKET_NOERROR if there is no error. Function working only for UDP socket type.

virtual int iNetworkSocket2::SetSocketBlock bool    block [pure virtual]
 

Sets the socket blocking operation if block is true, or unsets the blocking operation if block is false.

Returns CS_NET_SOCKET_NOERROR if there is no error.

virtual int iNetworkSocket2::SetSocketBroadcast bool    broadcast [pure virtual]
 

Sets the broadcast option on socket if broadcast is true, otherwise the broadcast option is unset.

Returns CS_NET_SOCKET_NOERROR if there is no error. Function working only for UDP socket type.

virtual int iNetworkSocket2::SetSocketReuse bool    reuse [pure virtual]
 

Sets the reuse option on a server socket if reuse is true, otherwise the reuse option is unset.

Returns CS_NET_SOCKET_NOERROR if there is no error.

virtual int iNetworkSocket2::WaitForConnection int    source,
int    port,
int    queue
[pure virtual]
 

Binds to the interface source on port port.

`source' is a numeric representation of a host address stored in network byte order, such as those returned by inet_addr(). `port' is the port number in host byte order on which to listen. Listens on bound socket - queing up to `queue' number of connections. Returns CS_NET_SOCKET_NOERROR if there is no error.


The documentation for this struct was generated from the following file:
Generated for Crystal Space by doxygen 1.2.14