Jump to content

  • Log In with Google      Sign In   
  • Create Account


data mingling


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
14 replies to this topic

#1 Jeremiah   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 February 2000 - 03:26 PM

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?

Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9339

Like
Likes
Like

Posted 09 February 2000 - 03:58 AM

Are you asking how to code so that you don''t have data mingling? Or are you asking how the IP stack works?

#3 Jeremiah   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 February 2000 - 04:31 AM

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.

#4 Sphet   Members   -  Reputation: 631

Like
Likes
Like

Posted 09 February 2000 - 05:17 AM

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..

#5 Jeremiah   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 February 2000 - 05:47 AM

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?

#6 SiCrane   Moderators   -  Reputation: 9339

Like
Likes
Like

Posted 09 February 2000 - 06:28 AM

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.

#7 DavidRM   Members   -  Reputation: 270

Like
Likes
Like

Posted 09 February 2000 - 06:32 AM

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


#8 SiCrane   Moderators   -  Reputation: 9339

Like
Likes
Like

Posted 09 February 2000 - 08:40 AM

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.

#9 Jeremiah   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 February 2000 - 11:15 AM

thanx everybody for thier posts, that was exactly what I was looking for. =)

#10 Spiff   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 February 2000 - 06:53 PM

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

#11 kressilac   Members   -  Reputation: 110

Like
Likes
Like

Posted 10 February 2000 - 02:01 AM

This question relates to your other question Jeremiah. Thinking of the single process responses you might want to use the message queue style. If you have a client that is more important than another client you could always add priority to the queue and use a priority queue instead of just a plain queue. Any basic algorithm book should have priority queues detailed in them. When you program using a message queue make sure that you select() is timing out. You would not want your code to hang in the middle because your sitting there waiting on a client socket that is never going to answer.

Kressilac
ps Again I point to either the links mentioned here or a good MUD. MUDs are free source and usually have tried algorithms for handling sockets. Many muds handle up to 500 players at a time as well and probably could easily handle many more.

pps Where are you from in KY. I am from Louisville.



#12 Jeremiah   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 February 2000 - 04:44 AM

I'll have to go check through some MUD source then. =)

that should definately help in my chat server I am going to create. Another thing though, is that my AI World will need to send roughly 15 [1K each] a second to EACH client.
thats 15K/sec, and Im not sure if thats possible under a 56K modem. or whether the server can handle that much bandwidth and processing.

[btw I am from the Elizabethtown area]

Edited by - Jeremiah on 2/10/00 10:45:46 AM

#13 kressilac   Members   -  Reputation: 110

Like
Likes
Like

Posted 11 February 2000 - 05:04 AM

You can usually find ways to minimize bandwidth requirements. You will also have to test it and as you get familiar with the speeds you are getting and lag, etc., etc. you will be able to program for the networking conditions you are facing. A lot of times bandwidth issues are trial and error.

Kressilac


#14 Spellbound   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 February 2000 - 05:09 AM

You probably already know this, but you should _only_ send data that the client cannot figure out himself. For example if a character is walking in a straight line you only need to tell the client that once. After that the client can figure out where it will be at a later time, given that it nows the speed of the character.



#15 kressilac   Members   -  Reputation: 110

Like
Likes
Like

Posted 14 February 2000 - 02:52 AM

There is an article on either this site or Gamasutra regarding statistical prediction for use in dead reckoning which is what the post by spellbound is getting at.

Kressilac
ps Apply the only-send-what-is-needed attitude all the time and you will inherently minimize some of the data you are sending.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS