data mingling

Started by
13 comments, last by Jeremiah 24 years, 2 months ago
How does sockets deal with this problem: two clients send a server information at the same time. how does sockets keep both clients data seperate?
http://fakemind.com
Advertisement
Are you asking how to code so that you don''t have data mingling? Or are you asking how the IP stack works?
if a server can have multiple sockets open to different clients right? well, with only one modem to transfer data back and forth, how does the data not mingle.

this isnt a programming question, just a how does it work question.
http://fakemind.com
Each packet sent through TCP has addresses within it. The TCP/IP stack reads those so it knows which socket to send the data to, thereby giving the appearance of multiple ''lines'' over one phone line, network cable, etc..
I apologize for not fully understanding.

If two clients try to send a packet of data each to the server, how does the sockets keep one from interupting the others data?

Like if three people had radio transmittors.
person 1, 2, and 3. Lets say Persons 1 and 2 want to talk to person 3 at the same time over the transmittor. How would person 3 keep 1 and 2 from talking over each other, and to wait their turn before they can talk?
http://fakemind.com
Simplification:
Network communication works on several levels. The lowest level is physical, this encodes the data into 1''s and 0''s. Devices on the same physical connection have a protocol in understanding the 1''s and 0''s called a data-link protocol. On a data link layer, devices send back and forth little bundles of information called frames. At this level you can only communicate with machines on your physical medium. However, if you want to send an IP packet, you wrap it in a frame and send it to the router on your datalink. (For a modem user, this is just the modem server.) The router figures out where the packet is going, wraps it in a new frame, and sends it down a datalink to the next router towards the destination. Communicating via packets is called network layer.

So the server is receiving two packets from different clients. The router servicing the server gets the two packets, and wraps one packet in a frame and transmits it to the server and then wraps the other packet in a frame and transmits it to the server.

Only one thing is communicating with the server: the router, not the clients directly.

If you have more computers on your data-link than just the server and the router, say on an ethernet, there''s a protocol where machines wait their turn to talk on the wire.
Nothing ever *really* happens "at the same time". Ever.

But some people deal with what you describe by multi-threading, and giving each client a separate thread. The other popular solution (which we use) is the "message queue" approach. Essentially, you just "round robin" each of the client sockets and process whatever input they''ve received since the last time you came around.

DavidRM
Samu Games
quote:Original post by DavidRM
Nothing ever *really* happens "at the same time". Ever.

Sure it does. At least in networking. Transmission stomping occurs all the time on physical media. That''s why we have protocols like CMSA/CD and CMSA/CA. The end user is (and programmer, for the most part) is simply shielded from it, because network engineers do their job right.
thanx everybody for thier posts, that was exactly what I was looking for. =)
http://fakemind.com
Hey? What about broadband. This topic has been discussed ALOT here in Sweden, everyone''s talking about it and every damn company offers it (at a too high expense though) but not many people really knows what broadband really is.

Broadband is the ability to send data with full duplex simultaniously over a cable in different channels, like cable tv does. The technique when only one line exists and you have to do CMSA/CD and CMSA/CA like SiCrane said, or tokens in a token network or whatever, is called baseband.

(I hope the definition of broadband and baseband is clear, since I translated it from swedish )

Daniel Netz, Sentinel Design
============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown

This topic is closed to new replies.

Advertisement