Fixed line endings

This commit is contained in:
Robert Osfield 2016-06-06 14:37:33 +01:00
parent b85358b38a
commit ca633e8a5e

View File

@ -55,7 +55,7 @@ static void SockaddrFromIpEndpointName( struct sockaddr_in& sockAddr, const IpEn
memset( (char *)&sockAddr, 0, sizeof(sockAddr ) ); memset( (char *)&sockAddr, 0, sizeof(sockAddr ) );
sockAddr.sin_family = AF_INET; sockAddr.sin_family = AF_INET;
sockAddr.sin_addr.s_addr = sockAddr.sin_addr.s_addr =
(endpoint.address == IpEndpointName::ANY_ADDRESS) (endpoint.address == IpEndpointName::ANY_ADDRESS)
? INADDR_ANY ? INADDR_ANY
: htonl( endpoint.address ); : htonl( endpoint.address );
@ -69,9 +69,9 @@ static void SockaddrFromIpEndpointName( struct sockaddr_in& sockAddr, const IpEn
static IpEndpointName IpEndpointNameFromSockaddr( const struct sockaddr_in& sockAddr ) static IpEndpointName IpEndpointNameFromSockaddr( const struct sockaddr_in& sockAddr )
{ {
return IpEndpointName( return IpEndpointName(
(sockAddr.sin_addr.s_addr == INADDR_ANY) (sockAddr.sin_addr.s_addr == INADDR_ANY)
? IpEndpointName::ANY_ADDRESS ? IpEndpointName::ANY_ADDRESS
: ntohl( sockAddr.sin_addr.s_addr ), : ntohl( sockAddr.sin_addr.s_addr ),
(sockAddr.sin_port == 0) (sockAddr.sin_port == 0)
? IpEndpointName::ANY_PORT ? IpEndpointName::ANY_PORT
@ -115,10 +115,10 @@ public:
assert( isBound_ ); assert( isBound_ );
// first connect the socket to the remote server // first connect the socket to the remote server
struct sockaddr_in connectSockAddr; struct sockaddr_in connectSockAddr;
SockaddrFromIpEndpointName( connectSockAddr, remoteEndpoint ); SockaddrFromIpEndpointName( connectSockAddr, remoteEndpoint );
if (connect(socket_, (struct sockaddr *)&connectSockAddr, sizeof(connectSockAddr)) < 0) { if (connect(socket_, (struct sockaddr *)&connectSockAddr, sizeof(connectSockAddr)) < 0) {
throw std::runtime_error("unable to connect udp socket\n"); throw std::runtime_error("unable to connect udp socket\n");
} }
@ -131,21 +131,21 @@ public:
if (getsockname(socket_, (struct sockaddr *)&sockAddr, &length) < 0) { if (getsockname(socket_, (struct sockaddr *)&sockAddr, &length) < 0) {
throw std::runtime_error("unable to getsockname\n"); throw std::runtime_error("unable to getsockname\n");
} }
if( isConnected_ ){ if( isConnected_ ){
// reconnect to the connected address // reconnect to the connected address
if (connect(socket_, (struct sockaddr *)&connectedAddr_, sizeof(connectedAddr_)) < 0) { if (connect(socket_, (struct sockaddr *)&connectedAddr_, sizeof(connectedAddr_)) < 0) {
throw std::runtime_error("unable to connect udp socket\n"); throw std::runtime_error("unable to connect udp socket\n");
} }
}else{ }else{
// unconnect from the remote address // unconnect from the remote address
struct sockaddr_in unconnectSockAddr; struct sockaddr_in unconnectSockAddr;
SockaddrFromIpEndpointName( unconnectSockAddr, IpEndpointName() ); SockaddrFromIpEndpointName( unconnectSockAddr, IpEndpointName() );
if( connect(socket_, (struct sockaddr *)&unconnectSockAddr, sizeof(unconnectSockAddr)) < 0 if( connect(socket_, (struct sockaddr *)&unconnectSockAddr, sizeof(unconnectSockAddr)) < 0
&& WSAGetLastError() != WSAEADDRNOTAVAIL ){ && WSAGetLastError() != WSAEADDRNOTAVAIL ){
throw std::runtime_error("unable to un-connect udp socket\n"); throw std::runtime_error("unable to un-connect udp socket\n");
} }
@ -157,7 +157,7 @@ public:
void Connect( const IpEndpointName& remoteEndpoint ) void Connect( const IpEndpointName& remoteEndpoint )
{ {
SockaddrFromIpEndpointName( connectedAddr_, remoteEndpoint ); SockaddrFromIpEndpointName( connectedAddr_, remoteEndpoint );
if (connect(socket_, (struct sockaddr *)&connectedAddr_, sizeof(connectedAddr_)) < 0) { if (connect(socket_, (struct sockaddr *)&connectedAddr_, sizeof(connectedAddr_)) < 0) {
throw std::runtime_error("unable to connect udp socket\n"); throw std::runtime_error("unable to connect udp socket\n");
} }
@ -200,7 +200,7 @@ public:
struct sockaddr_in fromAddr; struct sockaddr_in fromAddr;
socklen_t fromAddrLen = sizeof(fromAddr); socklen_t fromAddrLen = sizeof(fromAddr);
int result = recvfrom(socket_, data, size, 0, int result = recvfrom(socket_, data, size, 0,
(struct sockaddr *) &fromAddr, (socklen_t*)&fromAddrLen); (struct sockaddr *) &fromAddr, (socklen_t*)&fromAddrLen);
if( result < 0 ) if( result < 0 )
@ -272,7 +272,7 @@ struct AttachedTimerListener{
}; };
static bool CompareScheduledTimerCalls( static bool CompareScheduledTimerCalls(
const std::pair< double, AttachedTimerListener > & lhs, const std::pair< double, AttachedTimerListener > & rhs ) const std::pair< double, AttachedTimerListener > & lhs, const std::pair< double, AttachedTimerListener > & rhs )
{ {
return lhs.first < rhs.first; return lhs.first < rhs.first;
@ -329,7 +329,7 @@ public:
void DetachSocketListener( UdpSocket *socket, PacketListener *listener ) void DetachSocketListener( UdpSocket *socket, PacketListener *listener )
{ {
std::vector< std::pair< PacketListener*, UdpSocket* > >::iterator i = std::vector< std::pair< PacketListener*, UdpSocket* > >::iterator i =
std::find( socketListeners_.begin(), socketListeners_.end(), std::make_pair(listener, socket) ); std::find( socketListeners_.begin(), socketListeners_.end(), std::make_pair(listener, socket) );
assert( i != socketListeners_.end() ); assert( i != socketListeners_.end() );
@ -365,7 +365,7 @@ public:
break_ = false; break_ = false;
// prepare the window events which we use to wake up on incoming data // prepare the window events which we use to wake up on incoming data
// we use this instead of select() primarily to support the AsyncBreak() // we use this instead of select() primarily to support the AsyncBreak()
// mechanism. // mechanism.
std::vector<HANDLE> events( socketListeners_.size() + 1, 0 ); std::vector<HANDLE> events( socketListeners_.size() + 1, 0 );
@ -381,7 +381,7 @@ public:
events[ socketListeners_.size() ] = breakEvent_; // last event in the collection is the break event events[ socketListeners_.size() ] = breakEvent_; // last event in the collection is the break event
// configure the timer queue // configure the timer queue
double currentTimeMs = GetCurrentTimeMs(); double currentTimeMs = GetCurrentTimeMs();
@ -474,7 +474,7 @@ SocketReceiveMultiplexer::SocketReceiveMultiplexer()
} }
SocketReceiveMultiplexer::~SocketReceiveMultiplexer() SocketReceiveMultiplexer::~SocketReceiveMultiplexer()
{ {
delete impl_; delete impl_;
} }