Changeset 5592 in orxonox.OLD for branches/network
- Timestamp:
- Nov 16, 2005, 2:12:30 PM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_socket.cc
r5577 r5592 10 10 11 11 ### File Specific: 12 main-programmer: Christoph , David Hasenfratz13 co-programmer: 12 main-programmer: Christoph Renner, David Hasenfratz 13 co-programmer: 14 14 */ 15 15 … … 33 33 NetworkSocket::NetworkSocket() 34 34 { 35 /* set the class id for the base object */ 36 this->setClassID(CL_NETWORK_SOCKET, "NetworkSocket"); 35 37 36 37 38 39 38 /* Init SDL_net */ 39 if(SDLNet_Init()==-1) 40 { 41 PRINTF(1)("SDLNet_Init: %s\n", SDLNet_GetError()); 40 42 return; 41 42 43 43 } 44 else 45 PRINTF(5)("SDL_net initialized\n"); 44 46 45 47 } … … 51 53 { 52 54 53 54 55 55 /* Quit SDL_net */ 56 SDLNet_Quit(); 57 PRINTF(5)("SDL_net shutdown\n"); 56 58 } 57 59 … … 63 65 { 64 66 65 66 67 68 67 /* Connect to the host and port contained in ip using a TCP connection. */ 68 tcpSocket = SDLNet_TCP_Open(&ip); 69 if(!tcpSocket) 70 { 69 71 PRINTF(1)("SDLNet_TCP_Open: %s\n", SDLNet_GetError()); 70 72 return; 71 73 } 72 74 73 75 } … … 87 89 { 88 90 89 90 91 /* Close the connection */ 92 SDLNet_TCP_Close(tcpSocket); 91 93 92 94 } … … 94 96 /** 95 97 * This function writes some bytes (data) to the network connection (if the connection is already 96 * estabilhed) otherwise it just does nothing (silently discarding the data). And writes some 98 * estabilhed) otherwise it just does nothing (silently discarding the data). And writes some 97 99 * warnings 98 100 */ -
branches/network/src/lib/network/network_socket.h
r5588 r5592 11 11 #include "netdefs.h" 12 12 13 /* include SDL_net header */14 #include "confincl.h"15 13 14 /* include base_object.h since all classes are derived from this one */ 15 #include "base_object.h" 16 16 17 17 /* using namespace std is default, this needs to be here */ 18 18 using namespace std; 19 19 20 class NetworkSocket 20 class NetworkSocket : public BaseObject 21 21 { 22 22 23 23 private: 24 25 26 27 24 IPaddress serverAddress; 25 unsigned int port; 26 TCPsocket tcpSocket; 27 UDPsocket udpSocket; 28 28 29 29 public:
Note: See TracChangeset
for help on using the changeset viewer.