in reply to Server/client sync - when can I write to a socket?

See the perl network examples at Prof Golden's Perl Client server basics. Of course, it is basic Perl, but modules like IO::Socket and IO::Select make things easier. As far as writing and receiving simultaneously, there are 3 solutions: use IO::Select, fork, or use threads. Generally select is used when the messages are short, because the server will only handle one client at a time. If big files are transferred, you usually using a forking design.

It's a big topic, and you can search google and groups.google.com for "perl server client", "perl server IO::Select", "perl multi-echo chat", etc. There are many variations on server client setups. In general, for a client, you want a forking client. When it connects, it immediately forks off, one fork is solely for receiving, and 1 fork for sending. See Simple bi-directional forking commandline client for a basic client that should work with almost any server, like a telnet client.


I'm not really a human, but I play one on earth Remember How Lucky You Are
  • Comment on Re: Server/client sync - when can I write to a socket?

Replies are listed 'Best First'.
Re^2: Server/client sync - when can I write to a socket?
by techcode (Hermit) on Oct 29, 2008 at 21:59 UTC
    Yeah but I'm limited to only one socket due to EMI/UCP specification that dates back to paging systems (though extended for SMS's).

    Anyway - yes forking method (IO::Socket::INET) is already used for the other protocol (SMPP) server - I just thought that module itself (Net::SMPP) is taking care of that synchronization - when in reality (since we figured that both sides can write at the same time) it is doing exactly the same as I need to do for UCP - each operation/message/reply sent to one another has a "stamp" by which you match operation and reply. Communication is async in that you can send several messages, and then latter get responses for all of those - that they are accepted/rejected.

    Now knowing that both sides can write to the socket at the same time - everything makes perfect sense.


    Have you tried freelancing/outsourcing? Check out Scriptlance - I work there since 2003. For more info about Scriptlance and freelancing in general check out my home node.