A
download NSocket.h
Language: C++
LOC: 36
Project Info
NNIM
Server: SourceForge
Type: cvs
...nnim\GNU\client\wx\include\
   NAbout.h
   NAutoDict.h
   NAutoTxt.h
   NChat.h
   NContact.h
   NContactEdit.h
   NContactTree.h
   NContactTreeXML.h
   NContactWiz.h
   NDerivedClasses.h
   NEvent.h
   newtoc.h
   NInclude.h
   NLog.h
   NLogin.h
   NMain.h
   NNets.h
   NNetworkServer.h
   NPrefGen.h
   NPrefNet.h
   NPrefs.h
   NPrefSec.h
   NProtocol_wdr.h
   NProtocolManager.h
   NResources_wdr.h
   NSocket.h
   NSocketServer.h
   NTaskbar.h
   NTreeCtrlXML.h
   NUserWiz.h
   NWizards_wdr.h
   NXpms.h

#ifndef KIM_SOCKET_H
#define KIM_SOCKET_H

#include "basenetwork.h"
#include "wx/socket.h"
#include "buffer.hpp"

using namespace std;

class Protocol;

/**
 * wxWindows implementation of the Network class
 *
 * This class encapsulates a socket and event functions
 * for cross-platform communication
 *
 * @author Jesse Lovelace
 * @version 0.1
 */

class wxNetwork: public Network, public wxSocketClient
{
public:

  enum{Connected,
          Closed,
          HostLookupFailure,
          ConnectionRefused,
          FailedRead,
          FailedWrite,
          NotConnected
          };

  wxNetwork(Protocol *proto);

  /**
     connect to a specified host returning a socket identifier

  */
  virtual int connectTo(string host,int port);

  /**
     true iff connected to a host
   */
  virtual bool isConnected();

  /**
     Return how much available data there is waiting to be read.
   */
  virtual int availableData() { return 0; }

  /**
     Return status
   */
  virtual int status() { return m_status;}

  /**
     Send data
  */
  virtual void sendData(const char *data,unsigned long len);
  virtual void sendData(const vbuf& data);
 
  /**
      Disconnect
  */
  virtual void disconnect();

  /**
     Call to retrieve all data available
  */
  virtual void socketData(char* &data,int &len);
  virtual void socketData(string & data);
  virtual void socketData(vbuf & data);

  /**
     update socket and check for data
  */
  virtual void checkForData();

  /**
      return socket handle
   */
  virtual int getSock() { return 0; }

  void connected();
  void connectionError(int error);
  void errClosed();

};

#endif

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us