|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.baidu.driver4j.bns.SocketUtils
public class SocketUtils
Utility tool class for Socket
| 构造方法摘要 | |
|---|---|
SocketUtils()
|
|
| 方法摘要 | |
|---|---|
static void |
closeSocket(Socket socket)
close socket safety |
static Socket |
createSocket(String host,
int port)
Create a simple socket client instance with default connectionTimeout and soTimeout |
static Socket |
createSocket(String host,
int port,
int connectionTimeout,
int readTimeout)
Create a simple socket client instance with connectionTimeout and soTimeout |
static String |
getDottedIP(int ip)
Convert integer IP to format of 'xxx.xx.xx.xx' string |
static String |
getIpByHost(String host)
get ip address by host name |
static String |
hexStringIp2DottedIp(String ipHex)
Convert Hex integer IP to format of 'xxx.xx.xx.xx' string |
static boolean |
isSocketConnected(Socket socket)
To check Socket instance if connected |
static byte[] |
readSocket(Socket socket)
|
static void |
writeSocket(Socket socket,
byte[] message)
Write bytes to socket |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public SocketUtils()
| 方法详细信息 |
|---|
public static String getDottedIP(int ip)
ip - IP of integer
public static String hexStringIp2DottedIp(String ipHex)
ipHex - IP of hex integer
public static String getIpByHost(String host)
host - name
public static Socket createSocket(String host,
int port)
throws IOException
host - remote host nameport - remote port
Socket instance
IOException - if an I/O error occurs when creating the socket.
public static Socket createSocket(String host,
int port,
int connectionTimeout,
int readTimeout)
throws IOException
host - remote host nameport - remote portconnectionTimeout - readTimeout -
IOException - if an I/O error occurs when creating the socket.public static void closeSocket(Socket socket)
socket - Socket instancepublic static boolean isSocketConnected(Socket socket)
Socket instance if connected
socket - Socket instance
public static void writeSocket(Socket socket,
byte[] message)
throws IOException
socket - Socket instancemessage - message to write out
IOException - if an I/O error occurs when creating the socket.
public static byte[] readSocket(Socket socket)
throws IOException
IOException
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||