我用java写了这段代码
public class Client
{
private static int _port;
private static Socket _socket;
public static void main(String[] args)
{
try
{
_port = 8071;
_socket = new Socket("localhost", _port);
Random rand = new Random();
int n = rand.nextInt(50) + 1;
DataOutputStream dos = new DataOutputStream(_socket.getOutputStream());
dos.writeInt(n);
dos.flush();
// Show the server response
DataInputStream din = new DataInputStream(_socket.getInputStream());
int ServerNumber= din.readInt();
System.out.println(ServerNumber);
String serverRandomString=din.readUTF();
System.out.println(serverRandomString);
din.close();
dos.close();
}
这是一个简单的套接字通信。我的服务器在 java 中,但我想尝试用 C 编写客户端。在 C 中有 DataOutputStream 和 DataInputStream 的替代方法吗?