*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget --HG-- branch : trunk
This commit is contained in:
@@ -4,39 +4,31 @@
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004-2007 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email [email protected].
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _SOCKETS_UdpSocket_H
|
||||
#define _SOCKETS_UdpSocket_H
|
||||
|
||||
#include "sockets-config.h"
|
||||
#include "Socket.h"
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
/** Socket implementation for UDP.
|
||||
\ingroup basic */
|
||||
class UdpSocket : public Socket
|
||||
@@ -48,14 +40,12 @@ public:
|
||||
\param ipv6 'true' if this is an ipv6 socket */
|
||||
UdpSocket(ISocketHandler& h,int ibufsz = 16384,bool ipv6 = false, int retries = 0);
|
||||
~UdpSocket();
|
||||
|
||||
/** Called when incoming data has been received.
|
||||
\param buf Pointer to data
|
||||
\param len Length of data
|
||||
\param sa Pointer to sockaddr struct of sender
|
||||
\param sa_len Length of sockaddr struct */
|
||||
virtual void OnRawData(const char *buf,size_t len,struct sockaddr *sa,socklen_t sa_len);
|
||||
|
||||
/** Called when incoming data has been received and read timestamp is enabled.
|
||||
\param buf Pointer to data
|
||||
\param len Length of data
|
||||
@@ -63,7 +53,6 @@ public:
|
||||
\param sa_len Length of sockaddr struct
|
||||
\param ts Timestamp from message */
|
||||
virtual void OnRawData(const char *buf,size_t len,struct sockaddr *sa,socklen_t sa_len,struct timeval *ts);
|
||||
|
||||
/** To receive incoming data, call Bind to setup an incoming port.
|
||||
\param port Incoming port number
|
||||
\param range Port range to try if ports already in use
|
||||
@@ -96,7 +85,6 @@ public:
|
||||
\param range Port range
|
||||
\return 0 if bind succeeded */
|
||||
int Bind(SocketAddress& ad,int range = 1);
|
||||
|
||||
/** Define remote host.
|
||||
\param l Address of remote host
|
||||
\param port Port of remote host
|
||||
@@ -120,7 +108,6 @@ public:
|
||||
\param ad Socket address
|
||||
\return true if successful */
|
||||
bool Open(SocketAddress& ad);
|
||||
|
||||
/** Send to specified host */
|
||||
void SendToBuf(const std::string& ,port_t,const char *data,int len,int flags = 0);
|
||||
/** Send to specified address */
|
||||
@@ -133,7 +120,6 @@ public:
|
||||
#endif
|
||||
/** Send to specified socket address */
|
||||
void SendToBuf(SocketAddress& ad,const char *data,int len,int flags = 0);
|
||||
|
||||
/** Send string to specified host */
|
||||
void SendTo(const std::string&,port_t,const std::string&,int flags = 0);
|
||||
/** Send string to specified address */
|
||||
@@ -146,18 +132,15 @@ public:
|
||||
#endif
|
||||
/** Send string to specified socket address */
|
||||
void SendTo(SocketAddress& ad,const std::string&,int flags = 0);
|
||||
|
||||
/** Send to connected address */
|
||||
void SendBuf(const char *data,size_t,int flags = 0);
|
||||
/** Send string to connected address. */
|
||||
void Send(const std::string& ,int flags = 0);
|
||||
|
||||
/** Set broadcast */
|
||||
void SetBroadcast(bool b = true);
|
||||
/** Check broadcast flag.
|
||||
\return true broadcast is enabled. */
|
||||
bool IsBroadcast();
|
||||
|
||||
/** multicast */
|
||||
void SetMulticastTTL(int ttl = 1);
|
||||
int GetMulticastTTL();
|
||||
@@ -177,14 +160,10 @@ public:
|
||||
bool IsBound();
|
||||
/** Return Bind port number */
|
||||
port_t GetPort();
|
||||
|
||||
void OnOptions(int,int,int,SOCKET) {}
|
||||
|
||||
int GetLastSizeWritten();
|
||||
|
||||
/** Also read timestamp information from incoming message */
|
||||
void SetTimestamp(bool = true);
|
||||
|
||||
protected:
|
||||
UdpSocket(const UdpSocket& s) : Socket(s) {}
|
||||
void OnRead();
|
||||
@@ -192,7 +171,6 @@ protected:
|
||||
/** This method emulates socket recvfrom, but uses messages so we can get the timestamp */
|
||||
int ReadTS(char *ioBuf, int inBufSize, struct sockaddr *from, socklen_t fromlen, struct timeval *ts);
|
||||
#endif
|
||||
|
||||
private:
|
||||
UdpSocket& operator=(const UdpSocket& ) { return *this; }
|
||||
/** create before using sendto methods */
|
||||
@@ -206,11 +184,8 @@ private:
|
||||
bool m_b_read_ts;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _SOCKETS_UdpSocket_H
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user