?? basesocket.h
字號:
#pragma once
#include <Windows.h>
#include <iostream>
#include <algorithm>
#include "Data.h"
//open a file in a specified mode, returns a smart pointer pointed to the FILE struct
std::tr1::shared_ptr<FILE> getfd(std::string filename, std::string mode);
//decode a task from a string named data;
void decode_task(std::string data, Task& task);
//encode a task with a specific instruction;
std::string encode_task(std::string istrct, Task task);
//a helper function for the decoding of task
std::string getsubstr(std::string& data, int& i , int& j);
class BaseSocket
{
public:
static const int ERR = -1;
BaseSocket(void);
~BaseSocket(void);
int Receive(const SOCKET&);
static int SendBuff(SOCKET socket, const char buff[]);
static int RecvBuff(SOCKET socket, char buff[]);
protected:
int Startup();
int Cleanup();
static const int PORT = 4000; //the server side port
static const char* IP_ADDRESS; //the ip address of server
struct sockaddr_in m_serverAddr;
int AddrLen;
private:
virtual int InitSocket() = 0; //Init socket
BaseSocket(const BaseSocket&); //forbide the copy constructor
BaseSocket& operator=(const BaseSocket&); //and the assignment operator
static DWORD WINAPI RecvThread(LPVOID lpParameter);
static DWORD WINAPI SendThread(LPVOID lpParameter);
WSADATA Ws;
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -