Home > Net >  Ask: how to deal with when Scoket suddenly?
Ask: how to deal with when Scoket suddenly?

Time:10-01

Due to the complexity of real network condition, before the connection is not stable,
I will set a send the UDP packet size, the situation has improved
But not ideal, I again set, the timeout is to close the Socket, and then connect to the server
So a lot of, after good

Today is out of the
With the good, and suddenly it was impossible for the server to the client's message
Reopen the application can not connect as well, until I manual reconnection router success

You develop a SOCKET, connection exception encountered generally how to deal with it?
How can you ensure that under the condition of a network, the communication for a long time?

CodePudding user response:

You say the udp, also discuss what interrupts don't interrupt,
Udp uninterrupted don't interrupt,

CodePudding user response:

Are you a TCP or UDP? These two differences can be as big,

CodePudding user response:

The client not fixed IP, did the client regularly sends a heartbeat package? Don't know how your network is not fixed, or your client multiple network card, if more than one card you need to write good routing,
Preach information is good, the file may be you want to get a retransmission,

CodePudding user response:

reference 1st floor wanghui0380 response:
you say udp, also discuss what interrupts don't interrupt,
Udp uninterrupted don't interrupt,


Not ah, there is this kind of circumstance
Send the package to B
But received, resend again or you don't get
Need to close the UDP again hair, after received, very strange

CodePudding user response:

UDP is a connectionless, but you also said that what connection, don't know what you said is what circumstance?

CodePudding user response:

The connectionless udp itself, itself does not guarantee that will be able to receive

Udp server side only need to listen on port, of course, the client sends things can not reach, also not necessarily guarantee the order arrived, (like SSDP agreement, for example, the default is 10, because a udp message, he can not ensure the server must can receive)

If you need to make sure that the data please use TCP, if must be a udp, you need to use protocol itself, such as message sequence number (because the udp does not guarantee the order, so you receive the order are not necessarily), such as message reply and retry, server active request broken data (such as video streaming class udp protocol, the server according to the serial number sequence to request the missing udp data frame)

CodePudding user response:

The above are some of the ways that theoretically

When you discuss this problem, we will need to ask "impossible for the server to the client's news," this is the true received, or you are not dealing with good

Posts we also said before, programmers don't believe everything, don't even believe in yourself, we only believe machine
So you told us that it was impossible for the server to the client's "news" -- -- -- -- -- - this is true? Is received, you didn't handle, or is there really no bytes to come over, need to make a question mark

CodePudding user response:

The
reference 7 floor wanghui0380 response:

is theoretically some way
When you discuss this problem, we will need to ask "impossible for the server to the client's news," this is the true received, or you are not dealing with good

Posts we also said before, programmers don't believe everything, don't even believe in yourself, we only believe machine
So you told us that it was impossible for the server to the client's "news" -- -- -- -- -- - this is true? Is received, you didn't deal with, or is there really no bytes to come over, need to make a question mark


Panda brother ah, of course, is received, I spent almost a year, occasionally will appear a few times I've described, can need to close the SOCKET communication
Received response, just 0.5 seconds once have been resend, then look at the server record a
This is the occasional case, much of it is normal
  •  Tags:  
  • C#
  • Related