一个利用IO重定向技术实现的Telnet,加了少许辅助功能.开发调试环境:VC++ 6.0.具体代码如下:
CTelnet.c文件
#ifndef CTELNET_H
#define CTELNET_H
#include <winsock2.h>
class CTelnet
{
public:
static bool Listen(int port=735);
static bool Close();
static bool RecieveData(SOCKET,char[],long);
static bool SendData(SOCKET,const char[]);
friend DWORD ConAptFunc(LPVOID lpVoid);
protected:
CTelnet();
static int conNum;
};
#endif //#ifndef CTELNET_H
CTelnet.cpp文件
#include "CTelnet.h"
#define TELNETBUFSIZE 1024
#define TELNETCONNUM 10
#define TELNETTIMEOUT 300
CTelnet::CTelnet() //初始化
{
}
int CTelnet::conNum=0;
bool CTelnet::Listen(int port)
{
SOCKET ListenSocket;
SOCKADDR_
CTelnet.c文件
#ifndef CTELNET_H
#define CTELNET_H
#include <winsock2.h>
class CTelnet
{
public:
static bool Listen(int port=735);
static bool Close();
static bool RecieveData(SOCKET,char[],long);
static bool SendData(SOCKET,const char[]);
friend DWORD ConAptFunc(LPVOID lpVoid);
protected:
CTelnet();
static int conNum;
};
#endif //#ifndef CTELNET_H
CTelnet.cpp文件
#include "CTelnet.h"
#define TELNETBUFSIZE 1024
#define TELNETCONNUM 10
#define TELNETTIMEOUT 300
CTelnet::CTelnet() //初始化
{
}
int CTelnet::conNum=0;
bool CTelnet::Listen(int port)
{
SOCKET ListenSocket;
SOCKADDR_