[boulder.pm] Socket troubles

Justin Crawford Justin.Crawford at cusys.edu
Tue Sep 19 11:01:57 CDT 2000


I'm trying to understand sockets.  I have set up a server & a client and I
can establish a connection, but the communication stops after the first
server-->client interaction.  So on my terminals it looks like this:

server> socket_test.pl
Server ready. Waiting for connections...
I said hello.

client> client_socket_test.pl
Someone's there!  They said:
"Hello?"
I asked if I was connected


At this point the client should send something back to the server, but it
doesn't get there.  I read that autoflushing is built in when using
IO::Socket (which I am, in version 5.003) so I'm assuming that there is
something else I'm forgetting to do.  But I don't know enough about IO to
say for sure that all the flushing that needs doing is being done.  Any
ideas out there?

Thanks a lot.

Justin Crawford
Oracle Database Administration
University Management Systems
303-492-9083


#SERVER-SIDE interaction
#...
  print $sock "Hello?\n";  #to client
  print "I said hello.\n"; #to STDOUT

  my $listening = <$sock>;                                 #from client
  print "He asked me was he connected, just like this:\n"; #to STDOUT
  print "\"$listening\"\n";                                #to STDOUT

  print $sock "Yes you're connected.\n"; #to client
  print "I told him he was.\n";          #to STDOUT

----------------------------------------------------
#CLIENT-SIDE interaction:
#...

my $listening = <$socket>; #from server
print "Someone's there!  They said:\n"; #to STDOUT
print "\"$listening\"";        #to STDOUT

print $socket "Am I connected?\n";   #to server
print "I asked if I was connected\n";#to STDOUT

my $waiting = <$socket>;                     #from server
print "He told me I was, just like this:\n"; #to STDOUT
print "\"$waiting\"";                        #to STDOUT

$socket->close;







More information about the Boulder-pm mailing list