Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабы / 2 / lab.03.by mice / claw / fake_socket
.h/*******************************************************************************
* file: fake_socket.h *
* version: 0.0.1 *
* author: d-evil [tmd] (mailto:d-evil.tmd@mail.ru) *
* description: not available *
*******************************************************************************/
#ifndef FAKE_SOCKET_INCLUDED
#define FAKE_SOCKET_INCLUDED
#include <afx.h>
#include <winsock2.h>
#include "cdm_addr_info.h"
////////////////////////////////////////////////////////////////////////////////
// CSocket declaration
class CSocket {
public:
CSocket();
~CSocket();
cdm_addr_info *iaddr() { return &_iaddr; }
SOCKET m_hSocket() const { return _sock; }
SOCKET sock() const { return _sock; }
bool is_binded() const { return _is_binded; }
bool is_connected() const { return _is_connected; }
int Create(unsigned short port = 0, int type = SOCK_STREAM,
long event = 0, char *addr = NULL);
int Bind(int port = 0, const char *const host = NULL);
int Listen(const int backlog = 5);
int CanRead(const int timeout_ms = 200);
int CanWrite(const int timeout_ms = 200);
int Accept(CSocket& csock, sockaddr *const saddr = NULL, int *const saddr_sz = NULL);
int Connect(const sockaddr *const saddr = NULL, const int saddr_sz = 0);
int Attach(const SOCKET sock);
int Receive(char *const buf, const int buf_sz, const int flags = 0);
int Send(const char *const buf, const int buf_sz, const int flags = 0);
int Close();
protected:
private:
SOCKET _sock;
cdm_addr_info _iaddr;
int _type;
bool _is_binded;
bool _is_connected;
};
#endif
Соседние файлы в папке claw