Changeset 17

Show
Ignore:
Timestamp:
09/22/05 12:20:12 (3 years ago)
Author:
ross
Message:

cleaned out win32 code from posix UdpSocket? implementation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • oscpack/trunk/ip/posix/UdpSocket.cpp

    r16 r17  
    1 /* 
    2   oscpack -- Open Sound Control packet manipulation library 
    3   http://www.audiomulch.com/~rossb/oscpack 
    4  
    5   Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com> 
    6  
    7   Permission is hereby granted, free of charge, to any person obtaining 
    8   a copy of this software and associated documentation files 
    9   (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 be 
    16   included in all copies or substantial portions of the Software. 
    17  
    18   Any person wishing to distribute modifications to the Software is 
    19   requested to send the modifications to the original developer so that 
    20   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 OF 
    24   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
    25   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
    26   ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
    27   CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    28   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
    29 */ 
    301#include "UdpSocket.h" 
    312 
    32 #ifdef WIN32 
    33 #include <winsock2.h>   // this must come first to prevent errors with MSVC7 
    34 #include <windows.h> 
    35 #include <mmsystem.h> // for timeGetTime() 
    36  
    37 typedef int socklen_t; 
    38 #endif 
    393 
    404#include <vector> 
     
    4711#include <string.h> // for memset 
    4812 
    49 #ifndef WIN32 
    5013#include <pthread.h> 
    5114#include <unistd.h> 
     
    5720#include <sys/time.h> 
    5821#include <netinet/in.h> // for sockaddr_in 
    59 #endif 
    6022 
    6123#include "PacketListener.h" 
     
    12486  ~Implementation() 
    12587  { 
    126 #ifdef WIN32 
    127     if (socket_ != -1) closesocket(socket_); 
    128 #else 
    12988    if (socket_ != -1) close(socket_); 
    130 #endif 
    13189  } 
    13290 
     
    163121      // unconnect from the remote address 
    164122     
    165 #ifdef WIN32 
    166       struct sockaddr_in unconnectSockAddr; 
    167       SockaddrFromIpEndpointName( unconnectSockAddr, IpEndpointName() ); 
    168  
    169       if( connect(socket_, (struct sockaddr *)&unconnectSockAddr, sizeof(unconnectSockAddr)) < 0  
    170           && WSAGetLastError() != WSAEADDRNOTAVAIL ){ 
    171         throw std::runtime_error("unable to un-connect udp socket\n"); 
    172       } 
    173 #else 
    174123      struct sockaddr_in unconnectSockAddr; 
    175124      memset( (char *)&unconnectSockAddr, 0, sizeof(unconnectSockAddr ) ); 
     
    180129        throw std::runtime_error("unable to un-connect udp socket\n"); 
    181130      } 
    182 #endif 
    183131    } 
    184132 
     
    313261SocketReceiveMultiplexer *multiplexerInstanceToAbortWithSigInt_ = 0; 
    314262 
    315 extern "C" static void InterruptSignalHandler( int ); 
    316 static void InterruptSignalHandler( int ) 
     263extern "C" /*static*/ void InterruptSignalHandler( int ); 
     264/*static*/ void InterruptSignalHandler( int ) 
    317265{ 
    318266  multiplexerInstanceToAbortWithSigInt_->AsynchronousBreak(); 
     
    456404      } 
    457405 
    458  
    459406      // execute any expired timers 
    460407      currentTimeMs = GetCurrentTimeMs(); 
     
    486433    break_ = true; 
    487434    // 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 
    489437  } 
    490438};