?? slot.cpp
字號:
#include "stdhdr.h"
#include "main.h"
#include "svc.h"
#include "slot.h"
CSlot::CSlot(CSvc *pSvc, SOCKET sockfd, int id)
{
char buf[80], num[17];
m_id = id;
m_sockfd = sockfd;
pSvc->AddSlot(this);
CSlot *pSlot = pSvc->m_pHead;
strcpy(buf, "User #");
strcat(buf, itoa(m_id, num, 10));
strcat(buf, " has arrived.");
pSvc->SendAll(buf, this);
}
CSlot::~CSlot()
{
char buf[80], num[17];
CSlot *pSlot = m_pSvc->m_pHead;
strcpy(buf, "User #");
strcat(buf, itoa(m_id, num, 10));
strcat(buf, " has just left.");
m_pSvc->SendAll(buf, this);
m_pSvc->RemoveSlot(this);
closesocket(m_sockfd);
}
void CSlot::Send(char *pszSend)
{
send(m_sockfd, pszSend, strlen(pszSend), 0);
}
int CSlot::Recv(char *pszRecv, int n)
{
return recv(m_sockfd, pszRecv, n, 0);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -