1

I am developing a testbed for cloud computing environment. I want to establish multiple client connection to a server. What I want is that, server first of all send a data to all the clients specifying sending_interval and then all the clients will keep on sending their data with a time gap of that time_interval (as specified by the server). Please help me out, how can I do the same using python socket program. (i.e. I want multiple client to single server connectivity and also client sending data with the time gap specified by server). Will be great-full if anyone can help me. Thanks in advance.

7
  • 2
    It's recommended that you use an existing framework such as gevent or twisted to aid you with this task. I'm not entirely sure what you need to do. Commented Jun 19, 2011 at 14:55
  • I just want that the server just sends an information (i.e. sampling time) to all the clients. Then, all the clients will keep on sending their data back to the server continuously within a time gap as specified in server's data (i.e. sampling time). Commented Jun 19, 2011 at 15:40
  • 1
    is your question "please implement this for me?" or what? Commented Jun 19, 2011 at 16:03
  • 1
    Use Twisted - It makes socket programming much easier, and it tutorial will help you. Commented Jun 19, 2011 at 17:03
  • OH Plz .. I don't want you to implement this for me .. I just want to know the way we can do this .. coz I think using simple socket code .. we can't connect multiple client to single server .. anyways .. thanks Taze T. Schnitzel .. but I also want to know .. how to implement "periodic timer" in python? Commented Jun 19, 2011 at 17:37

2 Answers 2

1

This problem is easily solved by the ZeroMQ socket library. It is production stable. It allows you to define publisher-subscriber relationships, where a publishing process will publish data on a port regardless of how many (0 to infinite) listening processes there are. They call this the PUB-SUB model; it's in their docs (link below).

It sounds like you want to set up a bunch of clients that are all publishers. They can subscribe to a controlling channel, which which will send updates to their configuration (how often to write). They also act as publishers, pushing out their own data at an interval specified by default/config channel/socket.

Then, you have one or more listening processes that listen to all the clients' published messages. Perhaps you could even have two listening processes, one for backup or DR, or whatever.

We're using ZeroMQ and loving the simplicity it gives; there's no connection errors because the publisher doesn't care if anyone is listening, and the subscriber can start before the publisher and if there's nothing there to listen to, it can just loop around and wait until there is.

Bindings are available in ALL languages (it's freaky). The Python binding isn't pure-python, it does require a C compiler, but is frighteningly fast, and the pub/sub example is a cut/paste, 'golly, it works!' experience.

Link: http://zeromq.org

There are MANY other methods available with this library, including message queues, etc. They have relatively complete documentation, too.

Sign up to request clarification or add additional context in comments.

Comments

1

Multi-Client and Single server Socket programming can be achieved by Multithreading in Socket Programming. I have implemented both the method:

  1. Single Client and Single Server
  2. Multiclient and Single Server

In my GitHub Repo Link: https://github.com/shauryauppal/Socket-Programming-Python

What is Multi-threading Socket Programming? Multithreading is a process of executing multiple threads simultaneously in a single process.

To understand well you can visit Link: https://www.geeksforgeeks.org/socket-programming-multi-threading-python/, written by me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.