Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Issue with Socket creation

by kprasanna_79 (Hermit)
on Jul 01, 2014 at 18:52 UTC ( [id://1091900]=perlquestion: print w/replies, xml ) Need Help??

kprasanna_79 has asked for the wisdom of the Perl Monks concerning the following question:

Revered Monks

I have the below code

use IO::Socket; chop (my $hostname = `hostname`); my $sock = new IO::Socket::INET ( PeerAddr => '10.106.2.43:25', LocalAddr => $hostname, Proto => 'tcp') || die "cant create socket$@\n"; print $sock "helo $hostname\n"; ($result = <$sock>); print $result."\n\n"; $sock->flush; print $sock "helo $hostname\n"; ($result = <$sock>); print $result."\n\n";
The first print gives the below
220 ildmailw102p Microsoft ESMTP MAIL Service, Version: 7.5.7601.17514 + ready at Tue, 1 Jul 2014 14:48:19 -0400
Where as subsequently it hangs without printing the second line.
Any advise here would really help

-Prasanna.K

Replies are listed 'Best First'.
Re: Issue with Socket creation
by Corion (Patriarch) on Jul 01, 2014 at 19:01 UTC

    Line endings in SMTP are \x0D\x0A, and you're sending only \n (assuming that you are on Unix).

    Is there any reason you are not using one of the SMTP modules?

    I'm also not sure what the SMTP spec says about repeated HELO commands.

    Have you used a network sniffer to check what actually goes over the wire? Maybe the remote end closed the connection or simply stops talking to you if you behave in a way that does not conform to the SMTP spec. Is there an error log at the remote end that you can inspect?

      Thanks corion a lot for your time

      I am using this in Unix server and this code was already running fine in the old HP UX server. We migrated to a new server but same flavor. Thats the only change recently happened and this is not working. This IO::Socket module was already used in the code and so i didnt distrub it. Would you please advise us on the network sniffing?

      -Prasanna.K

        Would you please advise us on the network sniffing?

        Take a look at Wireshark. Tips on how to use it are probably beyond the scope of the Monastery, but it's fairly self-explanatory anyway.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1091900]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 10:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found