资源描述:
《用perl语言进行socket编程之四--》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、用Perl语言进行Socket编程之四>>这是源码:#!/usr/bin/perl#test.pl#Authorhomepage:spot.126.usestrict;useSocket;my$pop3server="263.";my$port=110;$=1;print"Content-type:text/html";print"POP3";print"";my($a,$name,$aliases,$proto,$type,$len,$thataddr,$thisaddr,$i);my$AF_I=2;my$SOCK_STREAM=1;my$sockaddr="S
2、na4x8";($name,$aliases,$proto)=getprotobyname("tcp");($name,$aliases,$port)=getservbyname($port,"tcp")unless$port=~roto);if($mysocket){}else{print"不能打开socket:$!";exit(0);}my$mybind=bind(S,$this);if($mybind){}else{print"无法绑定!:$!";exit(0);}my$myconnect=connect(S,$that);if($myconnect){}e
3、lse{print"连接错误:$!";exit(0);}my$BUF="";my$SenderIP=recv(S,$BUF,596,0);if($SenderIP){}else{print"接收错误:$!";exit(0);}if(substr($BUF,0,3)eq"+OK"){}else{print"POP3服务器出错!";exit(0);}my$BUFFER="USERzhangsan";$BUFFER.=chr(13);$BUFFER.=chr(10);my$SENVAL=send(S,$BUFFER,0);if($SENVAL){}else{print"
4、发送错误:$!";exit(0);}my$BUF="";my$SenderIP=recv(S,$BUF,4096,0);if($SenderIP){}else{print"接收错误:$!";exit(0);}if(substr($BUF,0,3)eq"+OK"){}else{print"无此帐号!";exit(0);}$BUFFER="PASS12345678";$BUFFER.=chr(13);$BUFFER.=chr(10);my$SENVAL=send(S,$BUFFER,0);if($SENVAL){}else{print"发送错误:$!";exit(0)
5、;}$BUF="";my$SenderIP=recv(S,$BUF,196,0);if($SenderIP){}else{print"接收错误:$!";exit(0);}if(substr($BUF,0,3)eq"+OK"){}else{print"密码错误!";exit(0);}print密码是正确的!本程序版权归菜瓜乐园EOFexit(0);>>>>这篇文章来自..,。