📄 2003-01-02_csocket.h
字号:
/*
+-----------------------------------------------------------------------------+
| |
| csocket.h |
| Last change: yyyy-mm-dd |
| |
| Author: Jan Krumsiek |
| eMail: proxy@krumsiek.com |
| Web: http://www.krumsiek.com/proxy |
| |
| Copyright 2003 - Jan Krumsiek |
| This source code can freely be modified and redistributed. No liability |
| whatsoever is taken by the author for any use of this software. |
| |
| Description: |
| This is the base sockets class each platform socket implementation has |
| to inherit. It defines the interface all other program parts have to |
| use for using sockets. |
| |
+-----------------------------------------------------------------------------+
*/
#ifndef _CSOCKET_H_
#define _CSOCKET_H_
#include "proxymain.h"
// callback function typedefs
typedef LRESULT (CALLBACK *SubProc)(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
// typedefs for handler function signatures
typedef void (*t_data)(UINT socket, CHARPTR data, UINT length); // Data arrival
typedef void (*t_error)(UINT socket, UINT errorno, CHARPTR msg); // Error
typedef void (*t_accept)(UINT socket);
typedef void (*t_close)(UINT socket);
typedef void (*t_connect)(UINT socket);
// class declaration
class CSocket
{
public:
// all functions are declared as "virtual" which forces the
// child classes to define them with their own code
// function which connects to another host
virtual UINT Connect(CHARPTR host, USHORT port)=0;
// server function which let's the class listen on a port
virtual UINT Listen(UINT port)=0;
// closes a port
virtual void Close(UINT socket)=0;
// sends 'length' bytes from 'data' to 'socket'
virtual Send(UINT socket, CHARPTR data, UINT length)=0;
// sends the 0-terminated string 'data' to 'socket'
virtual Sendsz(UINT socket, CHARPTR data)=0;
// returns IP address of peer of socket 'socket'
virtual CHARPTR GetPeerIP(UINT socket)=0;
// function which tells the sockets class the addresses of all handlers
virtual SetEventHandlers(t_connect connproc, t_accept acceptproc,
t_close closeproc, t_data arrivalproc,
t_error errorproc)=0;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -