Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
vsnet_sockettcp.h
Go to the documentation of this file.
1
#ifndef VSNET_SOCKET_TCP_H
2
#define VSNET_SOCKET_TCP_H
3
4
#include <config.h>
5
6
#include "
vsnet_headers.h
"
7
8
#include <assert.h>
9
#include <map>
10
#include <list>
11
#include <queue>
12
#include <vector>
13
#include <sys/types.h>
14
15
#include "
vsnet_socketbase.h
"
16
#include "
vsnet_thread.h
"
17
#include "
packetmem.h
"
18
19
typedef
unsigned
char
u_int8_t
;
20
typedef
unsigned
int
u_int32_t
;
21
22
/***********************************************************************
23
* VsnetTCPSocket - declaration
24
***********************************************************************/
25
26
class
VsnetTCPSocket
:
public
VsnetSocket
27
{
28
public
:
29
//Needs to be public to get around a VC++ 6 bug that doesn't allow you to define functions that return private types in that class.
30
typedef
boost::shared_ptr< Packet >
PacketPtr
;
31
32
VsnetTCPSocket
(
int
sock,
const
AddressIP
&remote_ip,
SocketSet
&set );
33
34
virtual
~VsnetTCPSocket
();
35
36
virtual
bool
isTcp
()
const
37
{
38
return
true
;
39
}
40
41
virtual
int
optPayloadSize
()
const
;
42
virtual
int
queueLen
(
int
pri );
43
44
//virtual int sendbuf( PacketMem& packet, const AddressIP* to, int pcktflags );
45
virtual
int
sendbuf
(
Packet
*packet,
const
AddressIP
*to,
int
pcktflags );
46
virtual
int
recvbuf
(
Packet
*p,
AddressIP
*ipadr );
47
48
virtual
void
dump
( std::ostream &ostr )
const
;
49
50
virtual
bool
isActive
();
51
52
virtual
bool
lower_selected
(
int
datalen = -1 );
53
54
virtual
bool
need_test_writable
();
55
virtual
int
get_write_fd
()
const
;
56
virtual
int
lower_sendbuf
();
57
virtual
void
lower_clean_sendbuf
();
58
59
protected
:
60
virtual
void
child_disconnect
(
const
char
*s );
61
62
protected
:
63
//HTTP needs to be able to add raw data to send and receive.
64
/* --- BEGIN section for nonblocking receive support --- */
65
66
struct
Blob;
67
71
struct
Header
72
{
73
u_int32_t
_len
;
74
u_int8_t
_pri
;
75
u_int8_t
_flags
;
76
77
Header
()
78
{
79
_len
= 0;
80
_pri
= 1;
81
_flags
= 0;
82
}
83
84
Header
(
int
l )
85
{
86
_len
= htonl( l );
87
_pri
= 1;
88
_flags
= 0;
89
}
90
91
inline
u_int32_t
h_len
()
const
92
{
93
return
ntohl(
_len
);
94
}
95
};
96
103
Blob
*
_incomplete_packet
;
104
106
std::queue< PacketPtr >
_cpq
;
107
VSMutex
_cpq_mx
;
108
115
int
_incomplete_header
;
116
Header
_header
;
117
122
bool
_connection_closed
;
123
126
void
inc_pending
();
127
void
dec_pending
();
128
138
typedef
std::queue< PacketPtr >
SqQueue
;
139
typedef
std::queue< PacketMem >
SqQueueP
;
140
141
class
SqQueues
142
{
143
public
:
SqQueues
();
144
145
bool
empty
()
const
;
146
int
getLength
(
int
idx );
147
void
push
(
int
idx,
PacketPtr
m );
148
PacketPtr
pop
();
149
150
private
:
151
//int _debug_array[4];
152
153
std::map< int, SqQueue >_q;
154
int
_ct;
155
156
SqQueues
(
const
SqQueues
& );
157
SqQueues
& operator=(
const
SqQueues
& );
158
};
159
160
SqQueues
_sq
;
161
SqQueueP
_sq_current
;
162
size_t
_sq_off
;
163
VSMutex
_sq_mx
;
164
int
_sq_fd
;
165
166
/* --- END section for nonblocking receive support --- */
167
168
void
inner_complete_a_packet
(
Blob
*
b
);
169
170
void
private_nothread_conditional_write
();
171
172
private
:
176
int
_mtu_size_estimation;
177
178
private
:
VsnetTCPSocket
();
179
VsnetTCPSocket
(
const
VsnetTCPSocket
&orig );
180
VsnetTCPSocket
& operator=(
const
VsnetTCPSocket
&orig );
181
};
182
183
#endif
/* VSNET_SOCKET_TCP_H */
184
src
networking
lowlevel
vsnet_sockettcp.h
Generated on Fri May 29 2015 23:07:35 for Vegastrike 0.5.1 rc1 by
1.8.4