in reply to How to transmit complex data to client?

I have a perl TCP server,

Ok. I would take that to mean that that you have implemented a server using TCP/IP. You have used Perl as an implementation language at the server end. That is fine.

The server gets a "key" and then replies back with a "value".

I have no idea of what the server should send based upon what the client sent - that's a server spec.

The client requests (sends a question) and expects complex data from the server (gets an answer). The client is expected to be able to understand the response from the server to its question.

Or should I use multi process or threads? Whoa! A client server is already at least multi-process or multi-thread.

Sounds like you not have a working TCP/IP server.
Explain more what you are trying to do and I'm sure you will get help.

  • Comment on Re: How to transmit complex data to client?

Replies are listed 'Best First'.
Re^2: How to transmit complex data to client?
by JavaFan (Canon) on Aug 29, 2011 at 11:03 UTC
    A client server is already at least multi-process or multi-thread.
    Only in the sense that both server and client are (likely) different processes. Neither server nor client needs to be multi-process or multi-threaded.
      Ok, a select based server would not be either multi-threaded or multi-process. A select server is the least commonly implemented server model and is normally used for special high-performance response-time applications.

      So what?

      I doubt the OP has implemented a select server model.
      A fork-based server is much easier to implement.

      I think the OP should show a simple set of client <-> server code.
      I am very sure that Monks will help iron out the details if the OP gets "close to the goal".

        Even easier is to write a server than neither forks, uses threads, or even has a select loop. Call it a hunch, but I don't get the impression the OP is creating a large service which requires many clients to connect concurrently, each doing massive data transfers. If it's just one or a few clients who connect to the server infrequently, doing a single request for which data can easily be send back to, a simple server that does accept, read, send in a simple loop is often good enough (Been there, done that, didn't get a t-shirt).

        Not that the OP was asking how to write a client server system.

        A select server is the least commonly implemented server model

        Oh, really? I use event based model quite often, because it simple and resource efficient. Not only when I need performance, but when for example I have many long living connections with low traffic. Also if you look onto amount of modules that support this model (like POE, or AnyEvent) you wouldn't call it "least common".