in reply to Socket Questions

Adding use warnings; to the top of the script, I immediately get:

Name "main::send_date" used only once: possible typo at ...

So, that presumably needs to be $send_data.

You should also add use strict; to the top of the script and fix all the issues it reports.

There also seems to be problems with functionality. You have, for instance:

print "\nSEND( TYPE q or Q to Quit):";

but I can't see where you're capturing the user input.

As you're new to Perl, I'd also recommend you add use diagnostics; to the top of your script - this will provide more verbose messages.

You can also test the script without actually running it from the commandline by typing:

perl -c script_name

Finally, perlipc has lots of information about using sockets.

-- Ken

Replies are listed 'Best First'.
Re^2: Socket Questions
by packetstormer (Monk) on Nov 05, 2010 at 17:59 UTC
    I think I might have pasted the wrong worksheet the last time, this one is the one I am using (edited original post with code tags too). I will try the strict and diag settings too. What happens is the socket connects and the response from the server is dumped to screen. I then input my response and although I can see the <STIND> appear on the remote servers log the response from the server never appears on the perl app, if you know what I mean.

      When you post sentences like this:

      That is, I can't seem to keep sending the receivign.

      ...you have more important things to worry about than learning perl sockets.

      However, when dealing with sockets you have to realize that the data you send over a socket can be broken up into many chunks, and you can't know ahead of time how many chunks there will be. As a result, the other side(e.g. the server) has to know when to stop waiting for chunks of data to arrive and that your transmission is complete. Should the server stop trying to receive data after receiving one chunk of data? What if your data got broken up into three chunks? Should the server stop trying to receive data after reading three chunks? What if your data got sent in only one chunk? Then the server will wait indefinitely for two other chunks to arrive

      Because you can't know how many chunks your message will get broken into, you have to send some kind of signal to the server that it has read the end of your message. Is the server waiting until it reads "GOOGLEPLEX" before considering the transmission complete? Or, maybe its "THE END"? Did you add either of those to the end of the data you sent to the server?

      I suggest that before you try to interact with a remote server that you write your own server program to interact with your client program. Then you will hopefully see the issues involved in trying to determine when the other side has finished transmitting data.

      In the event you consider that too much bother, you have to realize that in order to communicate with a remote server, you have to know what 'protocol' the server expects you to use. That is, among other things, you must know what character(s) the server expects you to use to signal the end of your message.