Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vsnet_socketudp.h
Go to the documentation of this file.
1 #ifndef VSNET_SOCKET_UDP_H
2 #define VSNET_SOCKET_UDP_H
3 
4 #include "vsnet_headers.h"
5 #include <queue>
6 
7 #include "vsnet_socketbase.h"
8 #include "vsnet_thread.h"
9 #include "packetmem.h"
10 
11 /***********************************************************************
12 * VsnetUDPSocket - declaration
13 ***********************************************************************/
14 
16 {
17 public: VsnetUDPSocket( int sock, const AddressIP &remote_ip, SocketSet &set );
19 
20  virtual bool isTcp() const
21  {
22  return false;
23  }
24 
25  virtual int optPayloadSize() const;
26  virtual int queueLen( int pri );
27 
28  virtual bool isActive();
29 //virtual int sendbuf( PacketMem& packet, const AddressIP* to, int pcktflags );
30  virtual int sendbuf( Packet *packet, const AddressIP *to, int pcktflags );
31  virtual int recvbuf( Packet *p, AddressIP *ipadr );
32 
33  virtual bool lower_selected( int datalen = -1 );
34 
35  virtual void dump( std::ostream &ostr ) const;
36  virtual bool setRemoteAddress( const AddressIP &inp );
37 private:
38  struct Pending
39  {
40  Pending( const void *buffer, size_t size, AddressIP &addr ) :
41  mem( buffer, size )
42  , ip( addr )
43  {}
44 
45  PacketMem mem;
46  AddressIP ip;
47  };
48 
49  std::queue< Pending >_cpq;
50  VSMutex _cpq_mx;
51 
52  size_t _negotiated_max_size;
53  char *_recv_buf;
54 
55 private:
59  int _mtu_size_estimation;
60 
61 private: VsnetUDPSocket();
62  VsnetUDPSocket( const VsnetUDPSocket &orig );
63  VsnetUDPSocket& operator=( const VsnetUDPSocket &orig );
64 };
65 
66 #endif /* VSNET_SOCKET_UDP_H */
67