Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sockets - WTF to be frank

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
OK, would anyone care to explain how to use sockets with perl?
I've treid... and treid, but it never works out the way it should... could someone give me a basic example of how to communicate with an SMTP server, please?
Thanks
SIber-D
(siber-d@siberdude.com)
 
I have not done it myself and would rather give you a clear answer (not point you to yet another page), but, since no one else seems to be chiming in with any expertise........so............
I found this resource listed under 'communications' on Hopefully, this will help.


There are examples of simple servers and clients on this page.

good luck.




keep the rudder amid ship and beware the odd typo
 
heres an example... not a very good one, but an examle all the same.

##!/usr/bin/perl

use Socket;

$port = 25;
$server = "mail.unf.com";

socket(HANDLE, PF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2]);

connect(HANDLE, pack('Sna4x8', AF_INET, $port, (gethostbyname($server))[4]);

HANDLE->autoflush();


#end

you can then read or write to your socket just like any other file handle.

<HANDLE> to read;
print HANDLE to write;


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top