sprint 1-alpha
|
00001 /****************************************************************************** 00002 * Multi Platform Network Library 00003 * 00004 * Copyright (C) 2005-2011 Paolo Medici <www.pmx.it> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 * 00020 *******************************************************************************/ 00021 00027 #ifndef _SPRINT_NETTOOLS_H 00028 #define _SPRINT_NETTOOLS_H 00029 00030 #include <sprint/sysdef.h> 00031 00032 namespace sprint { 00033 00035 bool socket_bind(SOCKET s, WORD wPort); 00036 00038 bool socket_connect(SOCKET s, LPCSTR server_name, WORD port); 00039 00041 bool socket_accept(SOCKET s, SOCKET * target, sockaddr_in & addr); 00042 00046 int aff_write(SOCKET s, const char *mem, unsigned int len); 00047 00051 int aff_read(SOCKET desc, char *buffer, unsigned int len); 00052 00054 LPCSTR IdentifyError(UINT error); 00055 00057 int print_sockerr(); 00058 00059 BOOL CreateSocketAddress(sockaddr_in *target, LPCSTR server_name, UINT port); 00060 00062 BOOL CreateSocketByHostName(sockaddr_in *target, LPCSTR host_name); 00063 00065 SOCKET CreateBindSocket(WORD wPort, int type); 00066 00068 SOCKET ConnectToLocalHost(UINT port); 00069 00071 SOCKET ConnectToServer(sockaddr_in *target, int type); 00072 00074 SOCKET AcceptConnection(UINT port); 00075 00077 SOCKET ConnectToServerByName(LPCSTR server_name, WORD port, int type); 00078 00081 BOOL mcast_add_membership(SOCKET sd, LPCSTR mcastgroup, struct ip_mreq *pmreq); 00082 00083 BOOL mcast_drop_membership(SOCKET sd, struct ip_mreq *pmreq); 00084 00087 } 00088 00089 #endif