Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8682049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:40:02+00:00 2026-06-12T21:40:02+00:00

I’m working on a simple multiplayer online text game and I read select() and

  • 0

I’m working on a simple multiplayer online text game and I read select() and poll() were popular methods for multiplexing I/O.

I found this example in the GNU C docs, which uses select. I ran it and made 3 Python test clients that look like this:

import socket
import time

port = 5555
test = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
test.connect(('localhost', port))

while 1:
    test.send('aaaa')
    time.sleep(0.5)

Then I ran the clients (from the same computer that’s running the server) with different strings (aaaa, 55 and ..).

The output of the server was

Server: got message: `aaaa'
Server: got message: `55aa'
Server: got message: `aaaa'
Server: got message: `55aa'
Server: got message: `..aa'

The strings were getting mixed up.

Is this some kind of silly compilation error, an error in my test clients or the fact that I’m running clients and servers from the same computer? Or is this program telling me I shouldn’t use select for this purpose? Considering that I’ll use this for a multiplayer game server (which probably gets lots of messages per second), I don’t think I can let the messages get mixed up.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:40:03+00:00Added an answer on June 12, 2026 at 9:40 pm

    The clients and server are completely asynchronous. You don’t know which is going to get time on the CPU and in which order. The network also provides no guarantee about order of delivery (though TCP will ensure that the application sees data from a single client in the order it was sent).

    Select/poll return a list of sockets that have data to read. Make sure you read them all before calling select/poll again otherwise you will be prioritizing connections on lower-numbered ports.

    Note that a read is raw data, not terminated in any way, and so cannot be dumped directly as a string unless the sender included a NUL terminator in the write to its socket.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.