我正在使用SOCKS5创建代理客户端,在rfc1928中,我应该向服务器发送连接消息,然后服务器向我发送消息:
client send to server:
+----+----------+----------+
|VER | NMETHODS | METHODS |
+----+----------+----------+
| 1 | 1 | 1 to 255 |
+----+----------+----------+
and then server should return message following:
+----+--------+
|VER | METHOD |
+----+--------+
| 1 | 1 |
+----+--------+
我的下面的代码:
procedure TForm1.ConnectClick(Sender: TObject);
var
RecvBuff: TBytes;
fSize: Int64;
begin
with TcpClient do
begin
Connect;
// send \x01\x01\x05 to SOCKS5 server
IOHandler.WriteLn('#01#01#05');
fSize := IOHandler.ReadInt64;
IOHandler.ReadBytes(RecvBuff, fSize);
// Check server response is \x01\x01
if (TBytes[0] = byte('#01')) and (TBytes[1] = byte('#01')) then
begin
ShowMessage('Server responsed!');
end;
end;
end;
我是pascal的新手,我无法在Lazarus中编译此代码,找不到可运行的Indy TCP操作可运行的演示,并且我不知道pascal中的字节操作,请帮助我找出以上代码问题。