2 Copyright (C) 2004-2008 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef __JackNetWinSocket__
21 #define __JackNetWinSocket__
23 #include "JackNetSocket.h"
33 #define E(code, s) { code, s }
34 #define NET_ERROR_CODE WSAGetLastError()
35 #define StrError PrintError
37 typedef uint32_t uint
;
39 typedef struct _win_net_error win_net_error_t
;
47 SERVER_EXPORT
const char* PrintError(int error
);
49 //JeckNetWinSocket***************************************************************************
50 class SERVER_EXPORT JackNetWinSocket
55 SOCKADDR_IN fSendAddr
;
56 SOCKADDR_IN fRecvAddr
;
59 JackNetWinSocket(const char* ip
, int port
);
60 JackNetWinSocket(const JackNetWinSocket
&);
63 JackNetWinSocket
& operator=(const JackNetWinSocket
&);
68 int BindWith(const char* ip
);
69 int BindWith(int port
);
71 int ConnectTo(const char* ip
);
77 void SetPort(int port
);
81 int SetAddress(const char* ip
, int port
);
86 int GetName(char* name
);
87 int JoinMCastGroup(const char* mcast_ip
);
90 int SetOption(int level
, int optname
, const void* optval
, SOCKLEN optlen
);
91 int GetOption(int level
, int optname
, void* optval
, SOCKLEN
* optlen
);
94 int SetTimeOut(int usec
);
99 bool IsLocal(char* ip
);
102 int SendTo(const void* buffer
, size_t nbytes
, int flags
);
103 int SendTo(const void* buffer
, size_t nbytes
, int flags
, const char* ip
);
104 int Send(const void* buffer
, size_t nbytes
, int flags
);
105 int RecvFrom(void* buffer
, size_t nbytes
, int flags
);
106 int Recv(void* buffer
, size_t nbytes
, int flags
);
107 int CatchHost(void* buffer
, size_t nbytes
, int flags
);
110 net_error_t
GetError();