VSocket类

功能:提供平台无关的简单的套接字功能

剔除DSMPlugin和HTTP相关内容后,VSocket类如下:

======================================公有成员函数====================================

// Constructor/Destructor
  VSocket();
  virtual ~VSocket(); 

  // Create
  //        Create a socket and attach it to this VSocket object
  //  创建一个socket并将其连接到本VSocket对象
  VBool Create();

  // Shutdown
  //        Shutdown the currently attached socket
  //  停止当前已连接的socket
  VBool Shutdown();

  // Close
  //        Close the currently attached socket
  //  关闭当前已连接的socket
  VBool Close();

  // Bind
  //        Bind the attached socket to the specified port
  //  If localOnly is VTrue then the socket is bound only
  //        to the loopback adapter.
  //  将已连接的socket绑定到指定端口
  //  如果localOnly为VTrue,则只将socket绑定到回路适配器
  VBool Bind(const VCard port, const VBool localOnly=VFalse);

  // Connect
  //        Make a stream socket connection to the specified port
  //        on the named machine.
  //  将流socket连接到已知机器的指定端口上
  VBool Connect(const VString address, const VCard port);

  // Listen
  //        Set the attached socket to listen for connections
  //  将attached socket设为监听
  VBool Listen();

  // Accept
  //        If the attached socket is set to listen then this
  //        call blocks waiting for an incoming connection, then
  //        returns a new socket object for the new connection
  //  如果attached socket设为监听则Accept的调用会被阻止直到有
  //  新的连入连接,然后为新连接返回一个新的socket对象
  VSocket *Accept();

  // GetPeerName
  //        If the socket is connected then this returns the name
  //        of the machine to which it is connected.
  //        This string MUST be copied before the next socket call...
  //  返回socket连接到的机器的名称。下次调用前需将此名称保存 
  VString GetPeerName();

  // GetSockName
  //  If the socket exists then the name of the local machine
  //  is returned.  This string MUST be copied before the next
  //  socket call!
  //  socket存在则返回本地机器的名称。下次调用前需将此名称保存
  VString GetSockName();

  // Resolve
  //        Uses the Winsock API to resolve the supplied DNS name to
  //        an IP address and returns it as an Int32
  //  使用Winsock API将DNS名解析为IP地址,并返回一个Int32的地址值
  static VCard32 Resolve(const VString name);

  // SetTimeout
  //        Sets the socket timeout on reads and writes.
  //  设置读写超时
  VBool SetTimeout(VCard32 msecs);

  // Send and Read return the number of bytes sent or recieved.
  // 发送或接收数据,并返回发送或接收的字节数
  VInt Send(const char *buff, const VCard bufflen);
  VInt SendQueued(const char *buff, const VCard bufflen);
  VInt Read(char *buff, const VCard bufflen);

    
  //清除缓冲队列
  void ClearQueue();  

========================================保护成员===================================

  // The internal socket id
  int sock;  

  char queuebuffer[9000]; //数据缓冲区
  DWORD queuebuffersize; //缓冲长度 

VSocket.h中还定义了VSocketSystem类,它的大致作用是启动和卸载WS2_32.DLL 库,提供对Windows的兼容 

被引用的地方:
vncclient.cpp
vncclient.h
vncencoder.h
vnchttpconnect.cpp
vnchttpconnect.h
vncsockconnect.cpp
vncsockconnect.h
winvnc.cpp
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值