java Socket和apache TelnetClient
java.net包提供的 socket客户端连接通信和apache提供的telnet包 TelenetClient,同样是客户端连接通信的,两者有什么区别呢。
不管是从通信方式、协议,还有优缺点、应用场景 方面来说都可以,越详细越好~~
欢迎讨论哈~~~~
------解决方案--------------------第一个偶尔用,第2个完全没听说过,java提供TCP/IP通信的就这一个类,你说的第2个应该是在这个基础上做了一层封装吧,个人感觉,也许第2个用起来方便点,但是当你发现它提供的功能,不能满足你的需求的时候,想改就麻烦了,还是建议直接用Socket吧
------解决方案--------------------这个看API就很清楚了啊,
首先TelnetClient继承SocketClient,而SocketClient的功能基本上和Socket差不多。。所以多出来的就是TelnetClient的新加的功能了。具体还是看API吧:http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/telnet/TelnetClient.html
public class TelnetClient
extends SocketClient
The TelnetClient class implements the simple network virtual terminal (NVT) for the Telnet protocol according to RFC 854. It does not implement any of the extra Telnet options because it is meant to be used within a Java program providing automated access to Telnet accessible resources.
The class can be used by first connecting to a server using the SocketClient connect method. Then an InputStream and OutputStream for sending and receiving data over the Telnet connection can be obtained by using the getInputStream() and getOutputStream() methods. When you finish using the streams, you must call disconnect rather than simply closing the streams.
------解决方案--------------------在一个功能上再次封装吧。