Java很强大,socket 通信几句就搞定。
服务端和客户端(最差的代码):
import java.net.*;
import java.io.*;
class ser
{
public static void main(String[] aa)
{
try{
ServerSocket sr=new ServerSocket(3000);
Socket s=sr.accept();
DataOutputStream o=new DataOutputStream(s.getOutputStream());
o.writeUTF("test Socket~~~~~~~~~~~~~~");
}catch(Exception ee){};
}
}
class cli
{
public static void main(String[] a)
{
try{
Socket c=new Socket("127.0.0.1",3000);
DataInputStream i=new DataInputStream(c.getInputStream());
System.out.println(i.readUTF());
}catch(Exception e){}
}
}
分享到:
相关推荐
8. **网络编程**:`WSAStartup`初始化网络套接字,`socket`创建套接字,`bind`绑定IP地址和端口,`connect`和`accept`处理客户端连接,`send`和`recv`发送和接收数据。 9. **文件和注册表操作**:`CreateFile`、`...
something about highest Asynchronous Performance development of Concurrent, may be the best docs you can find , thanks
- **4.1.33** `UPNP_E_NOT_FOUND [-507]`: Signals that something could not be found. - **4.1.34** `UPNP_E_INTERNAL_ERROR [-911]`: Indicates an internal error within the SDK. ##### 4.2 Constants, ...
"And Now for Something Completely Different . . . Again" Signs of the Python Times Why This Edition? Major Changes in This Edition Using the Examples and Demos Conventions Used in This Book...
SOCKET m_socket; // 定义一个套接字 ///////////////////////////////////////////////////////////////////////////// // CMy002App initialization BOOL CMy002App::InitInstance() { // *** 判断程序是否已...
.\Samples\delphi\SocketDemos Delphi Win32/Win64 Socket sample applications (all Delphi versions) .\Samples\delphi\sslinternet Delphi Win32/Win64 SSL-enabled sample applications (all Delphi versions) ....
they might mean something in the future. ; Directives following the section heading [PATH=/www/mysite] only ; apply to PHP files in the /www/mysite directory. Directives ; following the section ...
so Craig fixed it.- Warning: I‘ve put try/except in the TSakPOP.Connect and TSMTP.Connect function around the line FSocket.Open, so you will need to write something like: myPOP.Connect; if POPError ...