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 6853047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:27:52+00:00 2026-05-27T01:27:52+00:00

I am starting on a network-programming assignment I have. The instructions are as follows:

  • 0

I am starting on a network-programming assignment I have. The instructions are as follows:

a. Create n TCP clients and servers (together, the client and server on the
same host form a peer), where n is an input parameter.

b. Assign a virtual host name for each peer, e.g, Peer1, Peer2, etc.

c. Create an additional server that will act as the central server for
all peers.

d. Have all n peers connect to the central server, sending it a
“Hello” message.

e. Every second, have the central server send to a random selection of
n/2 peers the name of another, random peer.

f. The peers which have been contacted by the central server then
connect to the peer they have been given, and send it a random
number, which is echoed back.

e.g. for 2 peers:

Peer1: sending “Hello” to Central.

Central: received “Hello” from Peer 1.

Peer2: sending “Hello” to Central.

Central: received “Hello” from Peer 2.

Central: sending “Peer2” to Peer1.

Peer1: received “Peer2” from Central.

Peer1: sending “5890245” to
Peer2.

Peer2: received “5890245” from Peer1.

Peer2: sending “5890245”
to Peer1.

Peer1: received “5890245” from Peer2.

. . .

I am confused by the “virtual hostname” instruction in step b. What does it mean?

For the server, in Python I can do this:

hostname = #????
mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mySocket.bind((hostname, 50008))
mySocket.listen(1)

If hostname is ‘localhost’, or ”, it will only listen to connections from this machine. But if I try to give a name like ‘Peer1’, I get:

socket.gaierror: [Errno 8] nodename nor servname provided, or not known

presumably because it tries to connect to the host named “Peer1”, which doesn’t exist.

So how can I send one of my peers the “name” of another, and have it connect, if they’re all on my machine? My thoughts are that I’d just have to give them a port number as well, and have them all be “localhost”, but that doesn’t seem to be what is asked for.

If you have a language-agnostic, or other-language-specific answer, that would be just as appreciated! Thanks!

  • 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-05-27T01:27:52+00:00Added an answer on May 27, 2026 at 1:27 am

    The assignment is telling you to do the following:

    Create a group of client/server pairs. Each pair represents a single Peer, where the number of Peers is specified by the user. Assign a unique name (aka the virtual hostname) to each Peer that you create.

    Then have each Peer’s server socket open a listening port, and its client socket connect to the central server. One connected, the client socket sends its assigned Peer name to the server, so the server can keep a list of all available Peers.

    Then every second, the central server grabs a random selection of half of the connctions from its list and, for each connection it pulls out, writes the name of a random Peer to that conecton.

    On the receiving side, when a Peer’s client socket receives a name from the central server, create a separate connection to the server socket that is running on the specified Peer. That means the central server has to keep track of which IP belongs to which Peer (which it can grab when a Peer connects to it), and include that IP in the message that it sends out, so that the receiver knows where to connect to.

    Once that separate connection has been established, write a random number to it and wait for it to be echoed back.

    When a Peer’s server socket receives a message, echo it back to the client it came from.

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

Sidebar

Related Questions

For a TCP client connect() call to a TCP server.. UNIX® Network Programming book
I need to develop a client server system where I can have multiple clients
I'm just starting to learn how network programming in C works, and I've written
I'm starting to dip my toes in the world of network programming and I've
I'm starting to learn network programming in C++ and since the standard library doesn't
I'm starting to implement some sort of remote screencasting (VNC-alike) client/server software in C++
I am just starting out with network programming and I am having trouble keeping
I am starting to look into some network programming concepts for a project I
I am starting to create an MSAccess database, I have no Access experience -
My program does some network activity in a background thread. Before starting, it pops

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.