in reply to How to build a tcp session with a remote server?

It would help if you could explain exactly what you are going to be talking to?

Perl can do an amazing job at tcp/ip communication and it will work great!
But your client software needs to know the basic messaging protocol with the server.

The general idea is that you connect to a server who is listening on some port. Then as the client, you send information and the server responds. And that is normally how it goes...request/reply...request/reply.

A Perl client can do anything that a client written in C can do. At the end of the day, you need to explain what information you need to send to the server as the request and what you expect for it to send back as the response.
Tell us that information and it is easy to write the client.

There is no generic "hey, I can talk to any server" protocol.
The protocol is server specific. There will be a way for the server to understand that all of the information for a request has been received. Then the server does its magic. There will be a way for the client to understand that all of the information for a response to its request has been be received.

  • Comment on Re: How to build a tcp session with a remote server?

Replies are listed 'Best First'.
Re^2: How to build a tcp session with a remote server?
by JavaFan (Canon) on Aug 22, 2011 at 11:22 UTC
    There is no generic "hey, I can talk to any server" protocol.
    Well, there is in the (still broad) scope of his question. In fact, the name of the protocol is even mentioned in the title of his question: tcp.
    The protocol is server specific.
    Only in the sense there in theory there exists "servers" that don't have a TCP/IP stack. I seriously doubt that connecting to such servers even crossed the mind of the OP.
      Tcip/ip is a transport layer. It is a way for the client to shovel data bits into a pipe and for the server to read those bits. This lower level protocol ensures that the bits that I send is what you get.

      The next level higher is like: how many bits from you constitutes "one thing"? Maybe a fixed 256 bytes constitutes one "message". Maybe some string of characters which end in "\n" constitutes one "message". Maybe some number of lines that end in "\n" and a null line "\n" after all of the relevant lines constitutes collectively one "message". This is part of how the client "talks" to the server.

      This is client<->server message protocol specific. Perl is great at "\n" terminated messages! I print one line to you and then I receive one line back. Perl can also deal with fixed byte length message packets.

      Anyway all of this is related to the application I/F between client and server.

        Tcip/ip is a transport layer
        Assuming you mean TCP/IP here, you're wrong. Both TCP and IP are protocols (that's what the P in their names stand for). TCP is a protocol spoken on the transport layer (but there are more, of which UDP is probably the most well known). IP is another protocol, spoken on the internet layer (other protocols on said layer include ICMP, IGMP, and more).

        For the rest of your post, I've no idea what message you're trying to get across. But whatever it is, you're failing.