PDA

View Full Version : Packets!?



MrPinkPanther
29-07-2009, 07:18 AM
I'm really confused by the idea of packets. So lets say I have a client that sends my username "User=George" to the server and then it wants it to add it to User.txt and then recieve the list of Users in another packet. I know how to send and recieve packets I just don't get how to tell the server what to send back.

Could anyone help me please?

Jahova
29-07-2009, 08:20 AM
So say you send the server User=George, what was the packet that asked you to send that (from server) and what is the packet you receive after you have sent that (from server).

MrPinkPanther
29-07-2009, 07:04 PM
So say you send the server User=George, what was the packet that asked you to send that (from server) and what is the packet you receive after you have sent that (from server).
Basically I have no idea atall how packets work and I can't find an easy explination. I also don't know how to handle them on the server. I make a connection with the server and then what?

Colin-Roberts
29-07-2009, 09:47 PM
say like client sends user=george enters room, the server gets that, and then sends it to every other open client. to tell the other client that george is in the room.

Dentafrice
29-07-2009, 11:23 PM
Because it's not just about doing "User=George". Try something like this..

Client: @E|George| (@E being the enter packet, | being the start and end, and George being the username.).

Server: UL|George,Bill,Hill,Chill|



$packet = $_GET["packet"]; // get the whole packet.

$explode = explode('|', $packet);
$client_action = $explode[0]; // get the @E or whatever

$data = $explode[1]; // gets whatever is after the | and before the | so example: @E|Dentafrice| would get Dentafrice

switch($client_action) {
case '@E':
// do the user thing here.
echo "UL|" . $user->user_comma_list() . "|";
break;
}

MrPinkPanther
29-07-2009, 11:51 PM
So if used PHP to "GET" the packet then does it automatically send the packets to everyone else connected to the server? How small are packets averagely aswell. So how large would a packet such as "Bob, zak, harry" be?

Dentafrice
29-07-2009, 11:55 PM
So if used PHP to "GET" the packet then does it automatically send the packets to everyone else connected to the server? How small are packets averagely aswell. So how large would a packet such as "Bob, zak, harry" be?
No it doesn't automatically send it, I was just posting how the server could interpret it.

kickerbat
31-07-2009, 01:41 PM
Packet = Transfers data from A to B (A = input | B = the output).
@FlyDuo - You would want to encrypt packets so it all depends and if you could hint us what it will be for etc etc.

Want to hide these adverts? Register an account for free!