00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __INETWORK_DRIVER_H__
00021 #define __INETWORK_DRIVER_H__
00022
00023 #include "csutil/scf.h"
00024
00028 enum csNetworkDriverError
00029 {
00030 CS_NET_ERR_NO_ERROR,
00031 CS_NET_ERR_CANNOT_RESOLVE_ADDRESS,
00032 CS_NET_ERR_CANNOT_CONNECT,
00033 CS_NET_ERR_CANNOT_SEND,
00034 CS_NET_ERR_INVALID_SOCKET,
00035 CS_NET_ERR_CANNOT_BIND,
00036 CS_NET_ERR_CANNOT_LISTEN,
00037 CS_NET_ERR_CANNOT_CREATE,
00038 CS_NET_ERR_CANNOT_ACCEPT,
00039 CS_NET_ERR_CANNOT_SET_BLOCKING_MODE,
00040 CS_NET_ERR_CANNOT_RECEIVE,
00041 CS_NET_ERR_CANNOT_PARSE_ADDRESS,
00042 CS_NET_ERR_CANNOT_GET_VERSION,
00043 CS_NET_ERR_WRONG_VERSION,
00044 CS_NET_ERR_CANNOT_CLEANUP
00045 };
00046
00050 struct csNetworkDriverCapabilities
00051 {
00052 bool ConnectionReliable;
00053 bool ConnectionUnreliable;
00054 bool BehaviorBlocking;
00055 bool BehaviorNonBlocking;
00056 };
00057
00058
00059 SCF_VERSION (iNetworkEndPoint, 0, 0, 1);
00060
00066 struct iNetworkEndPoint : public iBase
00067 {
00069 virtual void Terminate() = 0;
00070
00072 virtual csNetworkDriverError GetLastError() const = 0;
00073 };
00074
00075
00076 SCF_VERSION (iNetworkConnection, 0, 0, 1);
00077
00082 struct iNetworkConnection : public iNetworkEndPoint
00083 {
00085 virtual bool Send(const void* data, size_t nbytes) = 0;
00086
00096 virtual size_t Receive(void* buff, size_t maxbytes) = 0;
00097 };
00098
00099
00100 SCF_VERSION (iNetworkListener, 0, 0, 1);
00101
00107 struct iNetworkListener : public iNetworkEndPoint
00108 {
00118 virtual iNetworkConnection* Accept() = 0;
00119 };
00120
00121
00122 SCF_VERSION (iNetworkDriver, 0, 0, 1);
00123
00128 struct iNetworkDriver : public iBase
00129 {
00141 virtual iNetworkConnection* NewConnection(const char* target,
00142 bool reliable, bool blocking) = 0;
00143
00153 virtual iNetworkListener* NewListener(const char* source,
00154 bool reliable, bool blockingListener, bool blockingConnection) = 0;
00155
00160 virtual csNetworkDriverCapabilities GetCapabilities() const = 0;
00161
00163 virtual csNetworkDriverError GetLastError() const = 0;
00164 };
00165
00166 #endif // __INETWORK_DRIVER_H__