ICS support mailing <twsocket@lists.elists.org>

Hi Simon

I run a card game. Protocol tcp. Users can play, chat, and send pictures / (very large) files. It's p2p. Every game can act as a server (if either the user opens a port or UPnP is enabled (then it's done by the game)).

Login: I use three servers - one main server and two backup servers. Users log in to one of the three servers. If the game acts as server, it posts it's port. If login is successful, the game gets the list of all servers (games) [IP:port] currently online - it connects to all these servers. [ After successful login I could shut down alle three login servers. Users who are online remain online - as everything is p2p. ] If you have a large number of users, you can either use different rooms (that is what I do - I limit my rooms to about 100 users) or your chat software just connects to a subset of all available servers.

If a game acts as server it knows about all users in the room. If not, the game mus update the list of all users currently online via one of the servers.

As in a network a lot of thing may go wrong every server S periodically sends
> the number of all servers it sees
> a f.e. md5 signature of the list of all servers
to every server in the room. If one of the servers K sees another number of servers or calculates another signature (sees the same number of servers but at least one is different) then K and S exchange the full list of servers. After that K and S connect to the "additional" servers.

Data from A to B is always sent directly (if A or B act as server) or(/and additonally) from A to at least one (fast) server (game) and from this server to B. A knows about the fastest paths from A to B (by checking "fast paths").

Chat messages: You must either "time stamp" each message in a p2p system - or just use the "fastest" server (game) currently online as chat server.

Files: If a user A sends a file f to B, then after successful transmission A and B act as file server for the file f: If A or B send this file f to another game C, then C "asks" all games that are directly connected if they are server for f. If A and B are connected to C then C receives a YES from A and B => C downloads f from A and B.

Data: As in a p2p system

-> every server (game) might logoff anytime (packet might get lost) and
-> data from X and Y is not always sent via the same server (it can happen that X sends D1 D2 - Y receives D2 D1)

I enumerate every packet sent from X to Y. Y buffers the received packets. If Y receives D1 D2 D4 then D1 D2 will be parsed and D4 buffered. If after a certain time (dependent on the "path time" X-Y) D3 is still not available to Y, then Y asks X to resend D3.

My packets look like this : [number of packet][length of packet][data][digital signature]

Best regards

Am 27.01.2016 um 14:19 schrieb Simon Lewis:
Am currently using ICS for a large chat system but now my service is getting 
bigger am starting to worry I not really done the socket code best I can below 
is the server side for receiving string commands also other idea am interested 
in looking into is a main server that controls other servers so can host 
multiple servers around world and main server will link them all and client 
will know were to connect.

procedure TComServer.SocketServerDataAvailable(Sender: TObject; ErrCode: Word);
   with Sender as TWSocketClient do
      RunCommand(ReceiveStr, Sender as TWSocketClient);

then the run common would split the string command in there own sections and 
read from array and assign correct string to dat[id]

procedure TComServer.RunCommand(comdata: string; rSocket: TWSocketClient);
   command: string;
   dat: array [0..50] of string;
   comdata := DecodeStr(comdata);

   while DecodeCommand(comdata, command, dat) do begin
   case StrToIntDef(command, -1) of
      00: LoginToService(dat[0], rSocket);

now am starting to think maybe string is not a good way to go about this on a 
large scale service so am wondering if anyone else has ever built a chat system 
and what methods did you use?, any information be great. Thanks a lot


To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to