Hpux telnet using socket

混江龙づ霸主 提交于 2019-12-08 05:24:42

问题


o Sun OS, UTS, AIX etc. But, when the same program is run with HP UX on the other end, we are unable to receive the response from the HP UX box (B.11.31 O/S).

sSocket = socket(AF_INET,SOCK_STREAM,0); 
connect(sSocket,(struct sockaddr *)&sin,sizeof(sin); 
ierr = read(sSocket,szBuffer,BUF_LEN-1); 

When the read is called, we get junk messages like this

Message received :ÿý$ 
Message received :ÿýÿþÿý 
Message received :ÿü!ÿû 

This code was working for all the other OSs like I stated earlier. Can somebody explain why this is happening. Note: We are able to login to HP box manually using telnet.


回答1:


These are telnet commands. Specifically "ÿ" is the Latin-1 graphic corresponding to the TELNET IAC (Interpret as Command) character, "ý" is the DO command, and "$" is the old ENVIRON option. It is intended that you send a WILL or WONT response. See the TELNET specification in RFC 854 for details.

I believe that some telnet servers do not send telnet commands until the client sends them first, which may explain why you do not see the issue with some servers.



来源:https://stackoverflow.com/questions/1189665/hpux-telnet-using-socket

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!