简体   繁体   中英

Remote UDP send and receive

Im trying to create a server/client application that will work on two or more remote computers with no local network between them. So i searched the internet and find a TON and TONES of C# UDP client/server examples just like here .

BUT i didn't find anywhere how to send a UDP socket over the internet on remote computer with, lets say IP="130.204.159.205";

please with your answers give me some example code

The example you linked shows how to create the socket , just remove the line IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName()) and put use this constructor and pass in a byte array with your ip address 130.204.159.205

(...)
// Connect to a remote device.
try {
    // Establish the remote endpoint for the socket.
    // This example uses port 11000 on the local computer.
    IPAddress ipAddress = new IPAddress(new byte[] { 130, 204, 159, 205});
    IPEndPoint remoteEP = new IPEndPoint(ipAddress,11000);
(...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM