Changeset 17
- Timestamp:
- 09/22/05 12:20:12 (3 years ago)
- Files:
-
- oscpack/trunk/ip/posix/UdpSocket.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
oscpack/trunk/ip/posix/UdpSocket.cpp
r16 r17 1 /*2 oscpack -- Open Sound Control packet manipulation library3 http://www.audiomulch.com/~rossb/oscpack4 5 Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>6 7 Permission is hereby granted, free of charge, to any person obtaining8 a copy of this software and associated documentation files9 (the "Software"), to deal in the Software without restriction,10 including without limitation the rights to use, copy, modify, merge,11 publish, distribute, sublicense, and/or sell copies of the Software,12 and to permit persons to whom the Software is furnished to do so,13 subject to the following conditions:14 15 The above copyright notice and this permission notice shall be16 included in all copies or substantial portions of the Software.17 18 Any person wishing to distribute modifications to the Software is19 requested to send the modifications to the original developer so that20 they can be incorporated into the canonical version.21 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.25 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.29 */30 1 #include "UdpSocket.h" 31 2 32 #ifdef WIN3233 #include <winsock2.h> // this must come first to prevent errors with MSVC734 #include <windows.h>35 #include <mmsystem.h> // for timeGetTime()36 37 typedef int socklen_t;38 #endif39 3 40 4 #include <vector> … … 47 11 #include <string.h> // for memset 48 12 49 #ifndef WIN3250 13 #include <pthread.h> 51 14 #include <unistd.h> … … 57 20 #include <sys/time.h> 58 21 #include <netinet/in.h> // for sockaddr_in 59 #endif60 22 61 23 #include "PacketListener.h" … … 124 86 ~Implementation() 125 87 { 126 #ifdef WIN32127 if (socket_ != -1) closesocket(socket_);128 #else129 88 if (socket_ != -1) close(socket_); 130 #endif131 89 } 132 90 … … 163 121 // unconnect from the remote address 164 122 165 #ifdef WIN32166 struct sockaddr_in unconnectSockAddr;167 SockaddrFromIpEndpointName( unconnectSockAddr, IpEndpointName() );168 169 if( connect(socket_, (struct sockaddr *)&unconnectSockAddr, sizeof(unconnectSockAddr)) < 0170 && WSAGetLastError() != WSAEADDRNOTAVAIL ){171 throw std::runtime_error("unable to un-connect udp socket\n");172 }173 #else174 123 struct sockaddr_in unconnectSockAddr; 175 124 memset( (char *)&unconnectSockAddr, 0, sizeof(unconnectSockAddr ) ); … … 180 129 throw std::runtime_error("unable to un-connect udp socket\n"); 181 130 } 182 #endif183 131 } 184 132 … … 313 261 SocketReceiveMultiplexer *multiplexerInstanceToAbortWithSigInt_ = 0; 314 262 315 extern "C" staticvoid InterruptSignalHandler( int );316 staticvoid InterruptSignalHandler( int )263 extern "C" /*static*/ void InterruptSignalHandler( int ); 264 /*static*/ void InterruptSignalHandler( int ) 317 265 { 318 266 multiplexerInstanceToAbortWithSigInt_->AsynchronousBreak(); … … 456 404 } 457 405 458 459 406 // execute any expired timers 460 407 currentTimeMs = GetCurrentTimeMs(); … … 486 433 break_ = true; 487 434 // FIXME: need to do something here to break through the select, not sure what 488 // for now single threaded apps will work fine because ct 435 // for now single threaded apps will work fine because ctrl-c will cause 436 // our select call to fall out with an E_INTR or something 489 437 } 490 438 };
