1 #ifndef __SOCKET_IP_H__ 2 #define __SOCKET_IP_H__ 5 #include "socket_portable.h" 6 #include "socket_address.h" 7 #include "typedObject.h" 43 inline static int GetLastError();
44 inline int SetNonBlocking();
45 inline int SetBlocking();
46 inline bool SetReuseAddress(
bool flag =
true);
48 inline int SetRecvBufferSize(
int size);
49 inline void SetSocket(SOCKET ins);
50 inline SOCKET GetSocket();
51 inline SOCKET GetSocket()
const;
55 inline static int InitNetworkDriver() {
return init_network(); };
59 inline bool ErrorClose();
68 friend class Socket_TCP_SSL;
76 register_type(_type_handle,
"Socket_IP",
77 TypedObject::get_class_type());
80 return get_class_type();
93 inline bool Socket_IP::ErrorClose()
107 return (_socket != BAD_SOCKET);
116 _socket = BAD_SOCKET;
145 _socket = BAD_SOCKET;
173 if (setsockopt(_socket, (
int) SOL_SOCKET, (
int) SO_RCVBUF, (
char *) &insize,
sizeof(
int)))
187 int flags = fcntl(_socket, F_GETFL, 0);
188 flags = flags | O_NONBLOCK;
189 fcntl(_socket, F_SETFL, flags);
192 unsigned long val = LOCAL_NONBLOCK;
193 unsigned lanswer = 0;
194 lanswer = SOCKIOCTL(_socket, LOCAL_FL_SET, &val);
210 int flags = fcntl(_socket, F_GETFL, 0);
211 flags &= ~O_NONBLOCK;
212 fcntl(_socket, F_SETFL, flags);
215 unsigned long val = 0;
216 unsigned lanswer = 0;
217 lanswer = SOCKIOCTL(_socket, LOCAL_FL_SET, &val);
231 if (setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (
const char *)&bOption,
sizeof(bOption)) != 0)
260 socklen_t name_len =
sizeof(name);
261 memset(&name,0,name_len);
263 getpeername(_socket,(sockaddr * )&name,&name_len);
268 #endif //__SOCKET_IP_H__ int SetRecvBufferSize(int size)
Ok it sets the recv buffer size for both tcp and UDP.
Base functionality for a TCP connected socket This class is pretty useless by itself but it does hide...
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Base functionality for a INET domain Socket this call should be the starting point for all other unix...
int SetBlocking()
Set the socket to block on subsequent calls to socket functions that address this socket...
int SetNonBlocking()
this function will throw a socket into non-blocking mode
Base functionality for a UDP Sending Socket.
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Socket_Address GetPeerName(void) const
Wrapper on berkly getpeername...
bool Active()
Ask if the socket is open (allocated)
Base functionality for a TCP rendezvous socket.
void SetSocket(SOCKET ins)
Assigns an existing socket to this class.
Base functionality for a combination UDP Reader and Writer.
Base functionality for a UDP Reader.
virtual ~Socket_IP()
Destructor.
A simple place to store and munipulate tcp and port address for communication layer.
Socket_IP()
Def Constructor.
static int GetLastError()
gets the last errcode from a socket operation
bool SetReuseAddress(bool flag=true)
Informs a socket to reuse IP address as needed.
void Close()
closes a socket if it is open (allocated)
TypeHandle is the identifier used to differentiate C++ class types.
SOCKET GetSocket()
Gets the base socket type.