00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_INETWORK_DRIVER_H__
00021 #define __CS_INETWORK_DRIVER_H__
00022
00023 #include "csutil/scf.h"
00024 #include "csutil/ref.h"
00025
00026 struct iString;
00027
00031 enum csNetworkDriverError
00032 {
00033 CS_NET_ERR_NO_ERROR,
00034 CS_NET_ERR_CANNOT_RESOLVE_ADDRESS,
00035 CS_NET_ERR_CANNOT_CONNECT,
00036 CS_NET_ERR_CANNOT_SEND,
00037 CS_NET_ERR_INVALID_SOCKET,
00038 CS_NET_ERR_CANNOT_BIND,
00039 CS_NET_ERR_CANNOT_LISTEN,
00040 CS_NET_ERR_CANNOT_CREATE,
00041 CS_NET_ERR_CANNOT_ACCEPT,
00042 CS_NET_ERR_CANNOT_SET_BLOCKING_MODE,
00043 CS_NET_ERR_CANNOT_RECEIVE,
00044 CS_NET_ERR_CANNOT_PARSE_ADDRESS,
00045 CS_NET_ERR_CANNOT_GET_VERSION,
00046 CS_NET_ERR_WRONG_VERSION,
00047 CS_NET_ERR_CANNOT_CLEANUP,
00048 CS_NET_ERR_NO_SUCH_OPTION,
00049 CS_NET_ERR_CANNOT_SET_OPTION
00050 };
00051
00057 struct csNetworkDriverCapabilities
00058 {
00059 bool ConnectionReliable;
00060 bool ConnectionUnreliable;
00061 bool BehaviorBlocking;
00062 bool BehaviorNonBlocking;
00063 };
00064
00065
00066 SCF_VERSION (iNetworkEndPoint, 0, 1, 1);
00067
00073 struct iNetworkEndPoint : public iBase
00074 {
00076 virtual void Terminate() = 0;
00077
00079 virtual bool SetOption (const char *name, int value) = 0;
00080
00082 virtual csNetworkDriverError GetLastError() const = 0;
00083 };
00084
00085
00086 SCF_VERSION (iNetworkConnection, 0, 1, 1);
00087
00092 struct iNetworkConnection : public iNetworkEndPoint
00093 {
00095 virtual bool Send(const char* data, size_t nbytes) = 0;
00096
00098 virtual bool IsConnected () const = 0;
00099
00109 virtual size_t Receive(void* buff, size_t maxbytes) = 0;
00110
00116 virtual size_t Receive(void* buff, size_t maxbytes, csRef<iString> &from) = 0;
00117
00123 virtual bool IsDataWaiting() const = 0;
00124 };
00125
00126
00127 SCF_VERSION (iNetworkListener, 0, 1, 1);
00128
00134 struct iNetworkListener : public iNetworkEndPoint
00135 {
00145 virtual csPtr<iNetworkConnection> Accept() = 0;
00146 };
00147
00148
00149 SCF_VERSION (iNetworkDriver, 0, 0, 2);
00150
00155 struct iNetworkDriver : public iBase
00156 {
00171 virtual csPtr<iNetworkConnection> NewConnection(const char* target,
00172 bool reliable = true, bool blocking = false) = 0;
00173
00187 virtual csPtr<iNetworkListener> NewListener(const char* source,
00188 bool reliable = true, bool blockingListener = false,
00189 bool blockingConnection = false) = 0;
00190
00197 virtual csNetworkDriverCapabilities GetCapabilities() const = 0;
00198
00202 virtual csNetworkDriverError GetLastError() const = 0;
00203 };
00204
00205 #endif // __CS_INETWORK_DRIVER_H__