Changeset 232 for trunk/src/game/WorldSocket.h
- Timestamp:
- 11/19/08 13:48:57 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/WorldSocket.h
r181 r232 56 56 * WorldSocket. 57 57 * 58 * This class is responsible for the com unication with58 * This class is responsible for the communication with 59 59 * remote clients. 60 60 * Most methods return -1 on failure. 61 * The class uses ref ferece counting.61 * The class uses reference counting. 62 62 * 63 63 * For output the class uses one buffer (64K usually) and 64 64 * a queue where it stores packet if there is no place on 65 65 * the queue. The reason this is done, is because the server 66 * does real y a lot of small-size writes to it, and it doesn't66 * does really a lot of small-size writes to it, and it doesn't 67 67 * scale well to allocate memory for every. When something is 68 * writ en to the output buffer the socket is not immideately68 * written to the output buffer the socket is not immediately 69 69 * activated for output (again for the same reason), there 70 70 * is 10ms celling (thats why there is Update() method). 71 * This concept is sim milar to TCP_CORK, but TCP_CORK72 * us ses 200ms celling. As result overhead generated by71 * This concept is similar to TCP_CORK, but TCP_CORK 72 * uses 200ms celling. As result overhead generated by 73 73 * sending packets from "producer" threads is minimal, 74 * and doing a lot of writes with small size is tol lerated.75 * 76 * The calls to Up ate () method are managed by WorldSocketMgr74 * and doing a lot of writes with small size is tolerated. 75 * 76 * The calls to Update () method are managed by WorldSocketMgr 77 77 * and ReactorRunnable. 78 78 * 79 79 * For input ,the class uses one 1024 bytes buffer on stack 80 * to which it does recv() calls. And then rec ieved data is81 * distributed where its needed. 1024 matches pr itey well the80 * to which it does recv() calls. And then received data is 81 * distributed where its needed. 1024 matches pretty well the 82 82 * traffic generated by client for now. 83 83 * 84 84 * The input/output do speculative reads/writes (AKA it tryes 85 * to read all data avai ble in the kernel buffer or tryes to86 * write everything avai ble in userspace buffer),87 * which is ok for using with Level and Edge Trig ered IO85 * to read all data available in the kernel buffer or tryes to 86 * write everything available in userspace buffer), 87 * which is ok for using with Level and Edge Triggered IO 88 88 * notification. 89 89 * … … 100 100 typedef ACE_Acceptor< WorldSocket, ACE_SOCK_ACCEPTOR > Acceptor; 101 101 102 /// Mutex type used for various sync ronizations.102 /// Mutex type used for various synchronizations. 103 103 typedef ACE_Thread_Mutex LockType; 104 104 typedef ACE_Guard<LockType> GuardType; … … 121 121 int SendPacket (const WorldPacket& pct); 122 122 123 /// Add ref ference to this object.123 /// Add reference to this object. 124 124 long AddReference (void); 125 125 126 /// Remove ref ference to this object.126 /// Remove reference to this object. 127 127 long RemoveReference (void); 128 128 … … 186 186 ACE_Time_Value m_LastPingTime; 187 187 188 /// Keep track of over speed pings ,to prevent ping flood.188 /// Keep track of over-speed pings ,to prevent ping flood. 189 189 uint32 m_OverSpeedPings; 190 190 … … 198 198 LockType m_SessionLock; 199 199 200 /// Session to which rec ieved packets are routed200 /// Session to which received packets are routed 201 201 WorldSession* m_Session; 202 202 203 /// here are stored the fragmen s of the recieved data203 /// here are stored the fragments of the received data 204 204 WorldPacket* m_RecvWPct; 205 205 206 206 /// This block actually refers to m_RecvWPct contents, 207 /// which al ows easy and safe writing to it.207 /// which allows easy and safe writing to it. 208 208 /// It wont free memory when its deleted. m_RecvWPct takes care of freeing. 209 209 ACE_Message_Block m_RecvPct; 210 210 211 /// Fragment of the rec ieved header.211 /// Fragment of the received header. 212 212 ACE_Message_Block m_Header; 213 213 214 /// Mutex for protecting o tuput related data.214 /// Mutex for protecting output related data. 215 215 LockType m_OutBufferLock; 216 216 … … 222 222 223 223 /// Here are stored packets for which there was no space on m_OutBuffer, 224 /// this al ows not-to kick player if its buffer is overflowed.224 /// this allows not-to kick player if its buffer is overflowed. 225 225 PacketQueueT m_PacketQueue; 226 226