简单的socket,连接不到阿里云的服务器。
package socket_guest;
import java.io.OutputStream;
import java.net.Socket;
public class socket
{
public static void main(String[] args) throws Exception
{
String host="/**/";
int port=2000;
Socket socket=new Socket(host,port);
OutputStream outputStream=socket.getOutputStream();
String message="amessage";
socket.getOutputStream().write(message.getBytes("UTF-8"));
outputStream.close();
socket.close();
}
}
package socket;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class receive
{
public static void main(String[] args) throws Exception
{
int port=2000;
ServerSocket server=new ServerSocket(port);
Socket socket=server.accept();
InputStream inputStream =socket.getInputStream();
byte[] bytes=new byte[1024];
int len;
StringBuilder sb=new StringBuilder();
while((le