#include <network_ip.h>
This class offers basic network connection functions to read/send data and manage connections.
Classes | |
class | Properties |
Private Member Functions | |
MAXON_INTERFACE (NetworkConnectionInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.networkconnection") | |
|
private |
MAXON_METHOD Result<void> CloseConnection | ( | ) |
Closes a connection by closing the socket.
MAXON_METHOD Result<void> KillConnection | ( | ) |
Killing a connection and canceling the connected threads.
MAXON_METHOD Result<Int> BytesInInputBuffer | ( | ) |
Returns the number of bytes that is available in the receive buffer.
MAXON_METHOD Result<void> RecvBytes | ( | const Block< Byte > & | data | ) |
Reads the requested number of bytes from the connection. The function will not return before the number of requested bytes has been read or an error occurred.
[in] | data | Block for data buffer with requested number of bytes to read. |
MAXON_METHOD Result<Int> RecvBytesEOS | ( | const Block< Byte > & | data | ) |
Reads the requested number of bytes from the connection to the end of the stream. The function will not return before the number of requested bytes has been read, an error occurred or the stream has been closed.
[in] | data | Block for data buffer with requested number of bytes to read. |
MAXON_METHOD Result<void> SendBytes | ( | const Block< const Byte > & | buffer | ) |
Sends the given number of bytes to the connection. The function will not return before the number of given bytes is sent or an error occurred. Full duplex connections will not flush the send buffer until FlushWriteBuffer() is called.
[in] | buffer | Block with the data to send. |
MAXON_METHOD Result<void> FlushWriteBuffer | ( | ) |
Flushes the write buffer and send the collected bytes to the network connection.
MAXON_METHOD Result<void> ResetBuffers | ( | ) |
Empties the read and write buffer for the next connection. This can be useful if the connection is of type keep alive.
MAXON_METHOD Int64 GetTransferedBytes | ( | ) | const |
Returns the number of transfered bytes. -1 if an error occurred.
MAXON_METHOD NetworkIpAddrPort GetRemoteAddr | ( | ) | const |
Returns the remote address of this connection.
MAXON_METHOD NetworkIpAddrPort GetHostAddr | ( | ) | const |
Returns the host address of this connection.
MAXON_METHOD SOCKET GetSocket | ( | ) | const |
MAXON_METHOD Result<void> SetNonBlockingSocket | ( | Bool | nonBlockingSocket | ) |
Enables or disables a non-blocking socket for this connection. For a blocking mode, send or receive calls will wait until they succeeded or the set timeout was reached. In the non-blocking mode a read operation would try and return immediately if no data was available.
[in] | nonBlockingSocket | Enabling or disabling the non-blocking socket |
MAXON_METHOD Bool IsNonBlockingSocket | ( | ) | const |
Returns if a non-blocking socket is used for the current connection.
MAXON_METHOD Result<void> SetUseNagleAlgorithm | ( | Bool | useNagleAlgorithm | ) |
Enables that Nagle algorithm of RFC 896, combining a number of small number of messages into one, reducing the overhead in transmission, but - on the flip side - increasing the latency of the transmission.
[in] | useNagleAlgorithm | Enabling or disabling the Nagle algorithm |
MAXON_METHOD Bool GetUseNagleAlgorithm | ( | ) | const |
Returns if the Nagle algorithm is used for the current connection.
MAXON_METHOD Result<void> SetTimeout | ( | TimeValue | timeoutInSeconds | ) |
Sets the timeout in case the current connection is blocked and can't send or receive. When exceeded the connection is closed.
[in] | timeoutInSeconds | The timeout value |
MAXON_METHOD TimeValue GetTimeout | ( | ) | const |
Returns the timeout set for the current connection.
MAXON_METHOD CONNECTIONTYPE GetConnectionType | ( | ) | const |
Returns the connection type of the current connection.
MAXON_METHOD void SetConnectionType | ( | CONNECTIONTYPE | type | ) |
Sets the connection type (Listener, Incomming, Outgoing) for the current connection
[in] | type | The type of the connection |
MAXON_METHOD void SetThread | ( | const ThreadRef & | ref | ) |
This function is private.
The current thread will always be checked for cancellation. You only have to set a thread if an additional thread should be checked for cancellation, too.
[in] | ref | An optional thread which will be checked for cancellation. |
MAXON_METHOD String GetProxyServerInfo | ( | ) | const |
Returns the stored proxy server information the was set using SetProxyInfo(). The format of the string is "<<server>>:<<port>>".
MAXON_METHOD void SetProxyServerInfo | ( | const String & | proxyInfo | ) |
Sets the proxy server to for later use of GetProxyInfo().
[in] | proxyInfo | Info to set. The format of the proxyInfo must be "<<server>>:<<port>>". |