Home > Net >  The use of NetMQ
The use of NetMQ

Time:11-11

Who is a great god can tell me how to judge NetMQ client and server disconnect, I now use only by the client, the server was developed by other companies, I can't judge whether the service side, can't determine when connection is broken, I know this DLL is disconnected automatically reconnection, but I need to judge the function of disconnect

CodePudding user response:

Class Program
{
The static void Main (string [] args)
{

Using (NetMQSocket clientSocket=new StreamSocket ())
{
NetMQProactor proactor=new NetMQProactor (clientSocket, intrinsic ProcessMessage);
NetMQBeacon n=new NetMQBeacon ();

Random rd=new Random();
Int num=rd. Next (0, 100);
ClientSocket. Connect (" TCP://127.0.0.1:5003 ");
While (true)
{
Console. WriteLine (num + ", both Please enter your message: ");
String message=Console. ReadLine ();
ClientSocket. SendMoreFrame (clientSocket. Options. Identity);
ClientSocket. SendFrame (num + ":" + message);
If (message=="exit")
{
break;
}
}
}
}
Public static void intrinsic ProcessMessage (NetMQSocket socket, NetMQMessage message)
{
Byte [] serverId=message. First. The ToByteArray (true);
String answer=System. Text. Encoding. The Default. Get string (message. Last. Buffer);
Console. WriteLine (" the Answer from the server: {0} ", Answer);
}

}

CodePudding user response:

The server was developed by other companies, can not ask them?

CodePudding user response:

A ping, ping can generally is not open,

CodePudding user response:

NetMQSocket I program inside this has been an error, don't know what circumstance, again, the lack of reference, has anyone bosses know it
  •  Tags:  
  • C#
  • Related