comparison core/UdpServer.cpp @ 53:6907e2177eb8 ultra-staging

Fixed bugs in Udp classes, updated tests
author Giulio Moro <giuliomoro@yahoo.it>
date Sun, 07 Jun 2015 14:58:34 +0100
parents f5b5c648cd5d
children d3f869b98147
comparison
equal deleted inserted replaced
44:f5b5c648cd5d 53:6907e2177eb8
32 return enabled; 32 return enabled;
33 } 33 }
34 34
35 bool UdpServer::bindToPort(int aPort){ 35 bool UdpServer::bindToPort(int aPort){
36 port=aPort; 36 port=aPort;
37 if(port<1){
38 enabled=false;
39 return false;
40 }
37 server.sin_port=htons(port); 41 server.sin_port=htons(port);
38 if (bind(inSocket,(struct sockaddr *)&server,length)<0){ 42 if (bind(inSocket,(struct sockaddr *)&server,length)<0){
39 enabled=false; 43 enabled=false;
40 return false; 44 return false;
41 } 45 }
46 enabled=true;
42 return true; 47 return true;
43 }; 48 };
44 int UdpServer::read(//Returns the number of bytes read, or -1 if there was an error. 49 int UdpServer::read(//Returns the number of bytes read, or -1 if there was an error.
45 void *destBuffer, 50 void *destBuffer,
46 int maxBytesToRead){ 51 int maxBytesToRead){