1 /* 2 Oddsock - DoSomething 3 Copyright (C) 2000 Oddsock 4 5 This program is free software; you can redistribute it and/or 6 modify it under the terms of the GNU General Public License 7 as published by the Free Software Foundation; either version 2 8 of the License, or (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 oddsock@oddsock.org 20 */ 21 // Socket.h: interface for the CMySocket class. 22 // 23 ////////////////////////////////////////////////////////////////////// 24 25 #if !defined(AFX_SOCKET_H__5EFF0BE2_257B_11D3_BF65_006008B82A90__INCLUDED_) 26 #define AFX_SOCKET_H__5EFF0BE2_257B_11D3_BF65_006008B82A90__INCLUDED_ 27 28 #if _MSC_VER > 1000 29 #pragma once 30 #endif // _MSC_VER > 1000 31 32 #ifdef WIN32 33 #include <winsock2.h> 34 #include <ws2spi.h> 35 #define SOCKET SOCKET 36 #else 37 #include <sys/types.h> 38 #include <sys/socket.h> 39 #include <netinet/in.h> 40 #include <unistd.h> 41 #include <string.h> 42 #include <netdb.h> 43 #ifdef _DMALLOC_ 44 #include <dmalloc.h> 45 #endif 46 47 #define SOCKET int 48 #define SOCKET_ERROR -1 49 #define closesocket close 50 #endif 51 52 53 class CMySocket 54 { 55 public: 56 CMySocket(); 57 virtual ~CMySocket(); 58 59 void initWinsockLib(void); 60 void socketErrorExit(char *szError); 61 SOCKET DoSocketListen(unsigned short portnum); 62 SOCKET DoSocketAccept(SOCKET s); 63 SOCKET DoSocketConnect(char *hostname, unsigned short portnum); 64 void CheckSocketError(int iError, char *szMessage); 65 void CleanAndExit(int iError); 66 67 // struct sockaddr_in connectedIP; 68 69 }; 70 71 #endif // !defined(AFX_SOCKET_H__5EFF0BE2_257B_11D3_BF65_006008B82A90__INCLUDED_) 72