Home > Back-end >  How to simulate a TCP connection protocol (such as the growing popularity of bettas are live sites)
How to simulate a TCP connection protocol (such as the growing popularity of bettas are live sites)

Time:11-16

Try to write a simulation method in Delphi, but through the way of packet of this simulation, I can only send 10 packets servers will be accepted in the past, to the 11th packet was rejected by the server, oneself also don't understand the knowledge of TCP protocol,

Consult everybody, how should to simulate such an agreement, let he can normal receiving,
Hope experts can tell I should start from which on the one hand, learning and how to simulate the packet, thank you!

I send my own Delphi code
Code can be a bit of a mess, I didn't post the server connection code, is my steps,
Connection bettas chat server, and then send anonymous login packet with a heartbeat packet simulation access (packet by wpe plaintext packet interception down, I will simulate such a clear packet processing login), but I'm so that simulation can only have 10 number of connections, 11 were rejected the connection,

 
Procedure TForm1. Button4Click (Sender: TObject);
Var
RequestStr BackStr: string;
Username: string;
Password: string;
Time: the string;
RoomID: string;
Salt: string;
Uuid: string;
Vitamin k: string;
P: string;
T1, t2: string;
The begin
Username:=';
Password:=';
Time:=IntToStr (DateTimeToUnix (Now) - 8 * 60 * 60);//timestamp
RoomID:=Edit1. Text;//room number
Salt:='7 oe9npeg9xxv69phu31fycluagkeytsf';//unknown values
Uuid: uuidsetup=();//16 hexadecimal random bytes
Vitamin k:=StrToMD5 (time + salt + vitamin k);//unknown values
='type @={p: loginreq/username @=/password @=/roomid @=' + roomid + '/ct @=2/devid @=' + uuid + '/ver @=20150505/rt @=' + time + '/vitamin k @=' + vitamin k + '/'; }
T1:=hextostring (' B8000000B8000000B1020000 ');
T2:=hextostring (' 00 ');
P:=t1 + 'type @=loginreq/+
'username @=' + username +/password @='+ password +'/roompass @=/roomid @='+
RoomID + + uuid '/devid @=' + '/rt @=' + time + + vitamin k + '/vitamin k @=' '/ver @=20150929/ct @=0/' + t2;
//memo1. Lines. The Add (p); }

If the socket. Connected then
The begin
RequestStr:=p;
Try
Socket. RecvBufferSize
Socket. Write (RequestStr);//send the login packet
Memo1. Lines. The Add (' send data: + RequestStr);
{t1:=hextostring (f0000001f000000b1020000 '1');
RequestStr:=t1 + 'type @=QRL/rid @=' + RoomID + '/' + t2; }
Heartbeat packets for the first time {}
T1:=hextostring (' 5 b0000005b000000b1020000 ');
P:=t1 + 'type @=keeplive/tick @=' + time;
Time:=IntToStr (DateTimeToUnix (Now) - 8 * 60 * 60);
Vitamin k:=StrToMD5 (time + salt + vitamin k);
P:=p + '/VBW @=0/CDN @ @=0/k=' + '/' vitamin k + + t2;
Heartbeat packets for the first time {}
Socket. Write (p);//for the first time heartbeat
BackStr:=socket. ReadLn (', 500);//in fact a timeout is ineffective, indy itself
//bug; At this point if the server end to the die such as
Memo1. Lines. The Add (' return data: + BackStr);

While (True) Do
The begin
T1:=hextostring (' 5 b0000005b000000b1020000 ');
Time:=IntToStr (DateTimeToUnix (Now) - 8 * 60 * 60);
Vitamin k:=StrToMD5 (time + salt + vitamin k);
Sleep (10000);
P:=t1 + 'type @=keeplive/tick @=' + time + '/VBW @=0/CDN @ @=0/k=' + '/' vitamin k + + t2;
Socket. Write (p);
Memo1. Lines. The Add (' send data: '+ p);
BackStr:=socket. ReadLn (', 500);//in fact a timeout is ineffective, indy itself
//bug; At this point if the server end to the die such as
Memo1. Lines. The Add (' return data: + BackStr);
end;

Except,
ShowMessage (' send data failed! ');
end;
End
The else
The begin
Memo1. Lines. The Add (' connection has been broken, can't send! ');
end;

CodePudding user response:

Here is the C/C + + zone, dephi zone left out, please,

CodePudding user response:

reference 1st floor paschen response:
here is the C/C + + zone, dephi zone left please go out,,


I will C and C + +, just for my own use written by Delphi, I just ask a HTTP and TCP protocol, the simulation principle of the code are the same!

CodePudding user response:

This is a link to send you the login 10 package?

CodePudding user response:

reference pathletboy reply: 3/f
this is a link you sent 10 login package?


10 connections 10 package, 11th connection sends the packet was rejected,

CodePudding user response:

Bettas are a port limit 10 links,

CodePudding user response:

reference 4 floor fengzi219 response:
Quote: reference pathletboy reply: 3/f

This is a link to send you the login 10 package?


10 connections 10 package, 11th connection to send packets were rejected,

Do you have Internet protocol over there

CodePudding user response:

Lot on the C source code, it is suggested that direct call C compiler DLL
Or an actual need transfer C DELPHI

Directly on www.github.com search serversocket
  • Related