inetwork/driver.h
00001 /* 00002 Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com> 00003 Written by Eric Sunshine <sunshine@sunshineco.com> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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 00058 struct csNetworkDriverCapabilities 00059 { 00060 bool ConnectionReliable; 00061 bool ConnectionUnreliable; 00062 bool BehaviorBlocking; 00063 bool BehaviorNonBlocking; 00064 }; 00065 00066 00067 SCF_VERSION (iNetworkEndPoint, 0, 1, 1); 00068 00074 struct iNetworkEndPoint : public iBase 00075 { 00077 virtual void Terminate() = 0; 00078 00085 virtual bool SetOption (const char *name, int value) = 0; 00086 00088 virtual csNetworkDriverError GetLastError() const = 0; 00089 }; 00090 00091 00092 SCF_VERSION (iNetworkConnection, 0, 1, 1); 00093 00098 struct iNetworkConnection : public iNetworkEndPoint 00099 { 00101 virtual bool Send(const char* data, size_t nbytes) = 0; 00102 00104 virtual bool IsConnected () const = 0; 00105 00115 virtual size_t Receive(void* buff, size_t maxbytes) = 0; 00116 00121 virtual size_t Receive(void* buff, size_t maxbytes, csRef<iString>& from)=0; 00122 00129 virtual bool IsDataWaiting() const = 0; 00130 }; 00131 00132 00133 SCF_VERSION (iNetworkListener, 0, 1, 1); 00134 00140 struct iNetworkListener : public iNetworkEndPoint 00141 { 00151 virtual csPtr<iNetworkConnection> Accept() = 0; 00152 }; 00153 00154 00155 SCF_VERSION (iNetworkDriver, 0, 0, 2); 00156 00161 struct iNetworkDriver : public iBase 00162 { 00184 virtual csPtr<iNetworkConnection> NewConnection(const char* target, 00185 bool reliable = true, bool blocking = false) = 0; 00186 00207 virtual csPtr<iNetworkListener> NewListener(const char* source, 00208 bool reliable = true, bool blockingListener = false, 00209 bool blockingConnection = false) = 0; 00210 00219 virtual csNetworkDriverCapabilities GetCapabilities() const = 0; 00220 00224 virtual csNetworkDriverError GetLastError() const = 0; 00225 }; 00226 00227 #endif // __CS_INETWORK_DRIVER_H__
Generated for Crystal Space by doxygen 1.2.18