• 大小: 8KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-27
  • 语言: 其他
  • 标签: socket  server  client  

资源简介

封装的非常完善的socket类,支持服务器客户端多个连接,调用起来非常方便

资源截图

代码片段和文件信息

#include “StdAfx.h“
#include “ClientSocket.h“

CClientSocket::CClientSocket(void)
{
m_pSocketobject = new CSocketobject();
}

CClientSocket::~CClientSocket(void)
{
if(m_pSocketobject->DeleteOrNot())
delete m_pSocketobject;
}
CClientSocket::CClientSocket(SOCKET s)
{
m_pSocketobject = new CSocketobject(s);
}
CClientSocket::CClientSocket(CClientSocket& clientSocket)
{
clientSocket.GetSocketobjectPointer()->PointerCopy();
m_pSocketobject = clientSocket.m_pSocketobject;
return;
}

BOOL CClientSocket::IsConnected()
{
return m_pSocketobject->IsConnected();
}

BOOL CClientSocket::Connect(CString pstrHost int nPort)
{
return m_pSocketobject->Connect(pstrHostnPort);
}
BOOL CClientSocket::ReadData( char* bufint lenint&recvlenint timeout)
{
return m_pSocketobject->Receive(buflenrecvlentimeout);
}
BOOL CClientSocket::ReadData( char* bufint lenint&recvlen)
{
return m_pSocketobject->Receive(buflenrecvlen);
}
BOOL CClientSocket::SendData(const char* bufint len)
{
return m_pSocketobject->Send(buflen);
}
void CClientSocket::Close()
{
m_pSocketobject->Close();
}
int CClientSocket::GetError()
{
return m_pSocketobject->GetError();
}

BOOL CClientSocket::SetDestinationIP(CString desIP)
{
return m_pSocketobject->SetDestinationIP(desIP);
}
CClientSocket& CClientSocket::operator=(CClientSocket& clientsocket)
{
if(m_pSocketobject->DeleteOrNot())
delete m_pSocketobject;
clientsocket.GetSocketobjectPointer()->PointerCopy();
m_pSocketobject = clientsocket.GetSocketobjectPointer();
return *this;
}
CSocketobject*CClientSocket::GetSocketobjectPointer()
{
return m_pSocketobject;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-07-29 14:07  ClinetServerSocket\
     文件        1680  2010-11-21 01:23  ClinetServerSocket\ClientSocket.cpp
     文件         809  2010-11-21 01:23  ClinetServerSocket\ClientSocket.h
     文件        2245  2013-08-07 17:09  ClinetServerSocket\ServerForOneClient.cpp
     文件         725  2010-12-01 11:56  ClinetServerSocket\ServerForOneClient.h
     文件        2322  2010-11-21 09:41  ClinetServerSocket\ServerSocket.cpp
     文件         624  2010-11-21 00:21  ClinetServerSocket\ServerSocket.h
     文件        5236  2012-11-13 19:08  ClinetServerSocket\Socketobject.cpp
     文件         835  2010-11-20 12:35  ClinetServerSocket\Socketobject.h
     文件        2077  2014-02-08 09:53  ClinetServerSocket\TCPServer.cpp
     文件         827  2010-11-21 19:34  ClinetServerSocket\TCPServer.h

评论

共有 条评论