cs sdk v 1.14 released

Home  |  Product  |  Documents  |  Tutorials  |  FAQ |   Download  |   Forum |   Contacts  |   Link  


  Cross Suit

 Cross Suit SDK

 Documents
      classes
 Starting...
           Tutorials

 LUA tutorials

   Support

  Forum
  q&a

 Product parts

 Virtual File system

 Virtual Render
 Virtual Machine
   

  Demo Games

   

 3D Engine

  gvSystem(dx9)

 Link

 

 

TCPClient.h

Go to the documentation of this file.
00001 /*
00002    Copyright (C) 2001 Nate Miller nkmiller@calpoly.edu
00003 
00004    This program is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU General Public License
00006    as published by the Free Software Foundation; either version 2
00007    of the License, or (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; if not, write to the Free Software
00016    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 
00018    See gpl.txt for more information regarding the GNU General Public License.
00019 */
00020 #ifndef __CLIENTH__
00021 #define __CLIENTH__
00022 
00023 // I #define all of these since I have no idea if they will be there on
00024 // non-Win32 platforms.  They were taken from winsock.h.
00025 #ifndef socket_t
00026 typedef unsigned int socket_t;
00027 #endif
00028 
00029 #ifndef INVALID_SOCKET
00030 #define INVALID_SOCKET (~0)
00031 #endif
00032 
00033 #ifndef INADDR_NONE
00034 #define INADDR_NONE (~0)
00035 #endif
00036 
00037 #ifndef SOCKET_ERROR
00038 #define SOCKET_ERROR -1
00039 #endif
00040 
00041 // see TCPClient.cpp for info
00042 struct TCPClient_t
00043 {
00044    TCPClient_t()          {sock =(unsigned int)INVALID_SOCKET;}
00045    virtual ~TCPClient_t() {Disconnect();}
00046 
00047    bool IsConnected() {return sock != INVALID_SOCKET;}
00048 
00049    bool Connect(const char *host, unsigned short port); 
00050    void Disconnect();
00051    bool Send(char *fmt, ...);
00052    int Read(char *dest, int &len); 
00053    bool CanRead();
00054 
00055 protected:
00056    static const int dataBuffSize;
00057    socket_t sock;
00058 };
00059 
00060 
00062 // Ãß°¡. 
00064 #include "dataBuff.h"
00065 class NetworkFile
00066 {
00067 public:
00068 #ifdef _DEBUG
00069         bool bloaded;           
00070 #endif
00071         dataBuff_t data;
00072         TCPClient_t client;
00073         char* netData;
00074         int size;
00075         int size_of_file;
00076         NetworkFile(const char* server_name, const char *name);
00077         ~NetworkFile();
00078 
00079         // http 1.0 Çì´õ ºÎºÐÀ» Á¦¿ÜÇÑ ºÎºÐ¸¸ µ¥ÀÌŸ·Î ÀúÀå.
00080         void OmmitHeader(unsigned char* pData)
00081         {
00082                 char* ppData = strstr((const char*)pData,"Content-Length: ");
00083                 if(ppData)
00084                         size_of_file = atoi(ppData+strlen("Content-Length: "));
00085 //              strstr((const char*)ppData,'
00086 /*              Parser::StartParseBuffer((const unsigned char*)pData,1024);
00087                 while(Parser::GetToken(true))
00088                 {
00089                         if(strnicmp(Parser::token,"Content",7)==0)
00090                                 break;
00091                 }
00092 */
00093         }
00094 };
00095 
00096 
00097 
00098 #endif
00099 
00100 
00101 
00102 

Copyright(C) gvSystem & GamePlus All Rights Reserved.