2 Copyright (C) 2008 Romain Moret at Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __JackNetWinSocket__
21 #define __JackNetWinSocket__
23 #include "JackNetSocket.h"
32 #define E(code, s) { code, s }
33 #define NET_ERROR_CODE WSAGetLastError()
34 #define StrError PrintError
36 typedef uint32_t uint
;
38 typedef struct _win_net_error win_net_error_t
;
46 SERVER_EXPORT
const char* PrintError ( int error
);
48 //JeckNetWinSocket***************************************************************************
49 class SERVER_EXPORT JackNetWinSocket
54 SOCKADDR_IN fSendAddr
;
55 SOCKADDR_IN fRecvAddr
;
58 JackNetWinSocket ( const char* ip
, int port
);
59 JackNetWinSocket ( const JackNetWinSocket
& );
62 JackNetWinSocket
& operator= ( const JackNetWinSocket
& );
67 int BindWith ( const char* ip
);
68 int BindWith ( int port
);
70 int ConnectTo ( const char* ip
);
76 void SetPort ( int port
);
80 int SetAddress ( const char* ip
, int port
);
85 int GetName ( char* name
);
86 int JoinMCastGroup ( const char* mcast_ip
);
89 int SetOption ( int level
, int optname
, const void* optval
, SOCKLEN optlen
);
90 int GetOption ( int level
, int optname
, void* optval
, SOCKLEN
* optlen
);
93 int SetTimeOut ( int usec
);
99 int SendTo ( const void* buffer
, size_t nbytes
, int flags
);
100 int SendTo ( const void* buffer
, size_t nbytes
, int flags
, const char* ip
);
101 int Send ( const void* buffer
, size_t nbytes
, int flags
);
102 int RecvFrom ( void* buffer
, size_t nbytes
, int flags
);
103 int Recv ( void* buffer
, size_t nbytes
, int flags
);
104 int CatchHost ( void* buffer
, size_t nbytes
, int flags
);
107 net_error_t
GetError();