Click here to Skip to main content
15,891,136 members
Everything / UDP

UDP

UDP

Great Reads

by Orekaria
Lightweight .Net library for UDP LAN broadcasting.
by honey the codewitch
Explore an Arduino based IoT web server and UDP multicaster for monitoring a remote water pump
by Zehaie M. Hailu
Python lends itself to the development of multi-threaded GUI and network applications.
by Huang Geng Geng
If you are looking for a tool

Latest Articles

by Mirzakhmet Syzdykov
Network programming in C++
by hemanthk119
This article describes modification of Arduino NINA firmware to wirelessly transmit I2S microphone data.
by Mark Beharrell
A queue based UDP protocol
by honey the codewitch
Explore an Arduino based IoT web server and UDP multicaster for monitoring a remote water pump

All Articles

Sort by Title

UDP 

5 May 2013 by evanharijanto
hello everyone, I'd like to ask why is this error occurs.I am trying to get a string data from a device. I have make this code and it runs well when I try to obtain data from a local server, but it stated this error when it connects to the device.java.net.PortUnreachableException: ICMP...
22 Jul 2014 by nitrous_007
Please help with this problem be patient and read through to the end. I will really appreciate it!!!I am creating 4 sockets on a computer with 4 network adapters and binding each socket to 1 network adapter. Network Adapter 1 is at 192.168.100.10. Socket 1 binds to Network Adapter...
22 Aug 2014 by nitrous_007
Nice article which might answer some of my questionshttp://msdn.microsoft.com/en-us/magazine/cc163648.aspx[^]In my code I am using syrnchronous ReceiveFrom function instead of the asyncronous BeginReceiveFrom. Is there any problem using the syncronous version as I am sending some data and...
28 Aug 2015 by nitrous_007
The solution turned out to be fixing the routes on the Test PC to make sure all the IP's were talking to correct network interfaces.
20 Dec 2012 by pokemonjohn
HiI have a UDP Listener running as a service on a server written in .Net which has been working fine, but now my client is using a VPN connection to the server as well.It seems that the UDP listener is not detecting any traffic from the VPN connectionI've tried binding it to...
7 Jan 2013 by pokemonjohn
I found out it was how a 3rd party was passing through the data to the VPN - once they changed a setting it all worked again !
6 Feb 2011 by pegaz9
Hi, i am from Poland and i am not fluent English.I am writting M.A thesis. Supervisor want that i programmed protocol communication but i doesnt know how to do it. It protocol should be do/has:- used socket(UDP protocol)- consisted of package, for example: init, bye ping, message,...
6 Feb 2011 by #realJSOP
You picked a programming project for your thesis, and you don't even LIKE programming? Beyond that, writing a thesis involves YOUR OWN research, not ours. research it, LEARN how to do it, and then write your thesis.
6 Feb 2011 by Espen Harlinn
You could do worse than starting out reading this book:http://www.cs.wustl.edu/~schmidt/POSA/POSA2/[^]It will not give you the answer, but it will enable you to understand how these things are usually done. Since you are writing a thesis, I would guess that you will have to understand the...
27 Oct 2013 by kleymanx90
hi,i have two packet Classes ,1- CommandPacket: class CommandPacket { /** @var CommandPacketHeader */ private $header; private $data;}and 2- CommandPacketHeader :class CommandPacketHeader { /** @var integer Cardinal */ private...
27 Oct 2013 by Richard MacCutchan
You already posted this at http://www.codeproject.com/Messages/4688029/how-can-i-split-an-object-into-chunks-and-send-the.aspx[^]. Please read the guidelines and use one forum only.
2 May 2013 by evanharijanto
Hi all, I'd like to ask a question.I would like to receive a data from an UDP port and display the data as string.here is my trial code, but it doesn't works.it is stated in the error message that it can't bind and also stated socket.bind(native method)I am still don't understand...
2 May 2013 by AlphaDeltaTheta
Well, your code is absolutely correct there is no issues with it.You are encountering a bind exception. Such exceptions occur if the underlying operating system is unable to create an socket at the specified port. It might be for the following reasons:1. The port 53 is already in use. In...
2 May 2013 by AlphaDeltaTheta
Well, your has no issues with it. Except for the thing that the constructor used to create a datagram socket for receiving must not include the ip address. It should be like thisDatagramPacket p = new DatagramPacket(buffer, buffer.length);You are encountering a bind exception. Such...
2 May 2013 by evanharijanto
solved!! thanks everyone!!here is the code I have made after some confusing period.import java.io.IOException;import java.net.DatagramPacket;import java.net.DatagramSocket;import java.net.InetAddress;import java.net.SocketException;public class udp_test{ public static void...
17 Oct 2022 by hemanthk119
This article describes modification of Arduino NINA firmware to wirelessly transmit I2S microphone data.
5 Nov 2020 by honey the codewitch
Explore an Arduino based IoT web server and UDP multicaster for monitoring a remote water pump
15 Oct 2010 by Andre Trollip
A simple set of classes to make creating Peer to Peer messaging easy using UDP. Features built-in message concatenation and delivery receipts for reliable transmission.
16 Sep 2013 by Member 9378296
I am trying to port an application from Windows to Android that uses datagramsockets for communication. (C# to Java)In the windows world, I created a messagereceived event listener that is automatically called when a UDP packet is received. The program continues to process data while it is...
7 Aug 2015 by suraty
Hello,How can I send a String array via Datagram packets?I can send a string, But how can I send an array? How can I receive it?
4 Apr 2011 by Member 3151821
Hi, All,I have an existing UDP Server Application that accepts incoming UDP packets and sends out UDP packets. The application is written in C++.I am now developting a new web site that wants to talk to the existing Server Application. So I am using UDPClient to send and receive packets...
4 Apr 2013 by Sandeep Mewara
Another homework question of the day? Same post by another member in 2 min: IP address assignment to server[^]It does not work like this here.Here is what is expected of enquirers:1. TRY first what you want to do! You may find that it's not that hard.2. Formulate what was done by you...
30 Jul 2013 by sugin.se
am Working with Asterisk Client softphone Design, Am using Asterisk as PBX Server, users are registered and configured to connect by UDP .But Server or client Blocks UDP connection. UDP connects via port 5060. I connects my designed softphone in this port and sends data. But i wont recieve...
16 Apr 2013 by Aayman Khalid
am trying to make an asynchronous udp chat application currently havung only one client and server.the problem is that when I run my server it displays a lot of redundant data and afterward whwn some text is typed displays the error"Error sending the file! \n"... Could someone please look at the...
12 Apr 2013 by ayesha hassan
I am working on udp server/client application. I want my single server to handle 40 clients at a time. For this, I want to create 40 dedicated threads, each dedicated for one single client. Since there are 40 threads one for each client, I want to create 40 dedicated sockets as well. But the...
12 Apr 2013 by jsolutions_uk
If you want a multi client server (who wouldn't?) you shouldn't need to listen on 40 different sockets, but rather a single socket. On recieving a connection, spawn a thread to handle the connection... or a process if you want to go old school :)In fact here's a good example Beginning...
12 Apr 2013 by Manfred Rudolf Bihy
You're trying this the wrong way round. The server should have one socket (IP-adress and port) on which it accepts connections and then it will spawn a separate thread for each client that connects. If you were to do it your way you'd need either 40 IP adresses and listening on one designated...
12 May 2013 by ayesha hassan
I had been working on a Server Client aplication where Server is going to service(sendto + receivefrom)'x' number of Clients at a time. For this purpose, I have created 'x' number of threads on Server side so that each thread is dadicated to one single client. Inside each thread there is a...
12 May 2013 by Sergey Alexandrovich Kryukov
I think that using threads with blocking sockets instead of asynchronous API is much better. In most cases, communication is sequential in its nature and the flow of operations is logically independent from other threads. Therefore, using a separate thread for each communication channel (in case...
2 Jul 2015 by Jak Vo
Hello all!I'm writing small app for sending text data via udp. On server side i have one async UDP socket for sending and receiving data. On client side i have same async UDP socket. When the client sends data to the server, then immediately exit the application without waiting for a...
2 Jul 2015 by Dave Kreskowiak
Why are you even using UDP? From what you describe, you cannot lose data.UDP doesn't guarantee the data gets to the destination and doesn't even guarantee the packets show up in the correct order!What you describe requires TCP, not UDP.UDP is used to broadcast connectionless data...
10 Jan 2012 by GabeA
I am currently working on a program that receives UDP packets of size 1460 bytes per packet and continuously streams the bytes to the hard drive of my PC. Currently, my program can only receive and stream 84 packets before data loss occurs. I need my program to be realtime with a fast sampling...
10 Jan 2012 by Richard MacCutchan
Why are you messing about with the data in this way? You receive a stream of bytes from the network so all you need to do is write that stream (whatever length you receive) to the disk. Don't try converting to a string (what does that achieve?) and don't write four bytes as an int.
10 Jan 2012 by CodyDaemon
I few things which should help on the speed front...Open the file and keep it open, and just write data to it as it comes in, and then close the file when the program exits. Open and closing files for each packet is just overhead which can easily removed.Why are you writing each 'int' by...
30 Nov 2014 by Member 11273665
I made an application for remote control a pc specifically for control the strategy game Age of Empires 3 (so I can control two civs using one pc). The application uses UDP protocol to send the captured image (I inject a dll to the age3.exe proccess and I hook the DirectX EndScene function so...
30 Nov 2014 by Dave Kreskowiak
Can it cause your hardware to fail? Nope.This sounds like an ISP problem or at most bad hardware and it's just a coincidence that your app happens to be running.
29 Jul 2013 by Klockness
I have several LANs(10.0.0.x) connected to a WAN(192.168.1.x). Each through a router that allows a network drirected broadcast. This is to allow the devices in the LANs to be discovered by devices on the WAN. I can send a broadcast on the LAN(10.0.0.255) and receive it on my socket. But when I...
29 Jul 2013 by freakyit
hi,just an idea:do you have activated port forwording to your ip-address ?greetz
7 Jun 2012 by Geno Carman
I create a socket and bind it to a unicast address. However, it reads packets sent to the broadcast address and I do not understand why.IPAddress ip;IPAddress.TryParse("X.X.X.99", out ip);Socket receiver = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,...
8 Jun 2012 by Geno Carman
This is broadcast, not multicast. the x.x.x.255 is a broadcast address.
22 Sep 2013 by radnix
Hi,I performed the Microsoft Udp examples successfully at :http://msdn.microsoft.com/en-us/library/tst0kwb1.aspxNeither of these two applications use "Bind".My application throws an error if I do not use Bind:ERROR: "You must call the Bind method before performing this...
22 Sep 2013 by Homero Rivera
On the second line of code you do not asign int.Parse to UdpRxPort. Not sure if that is the solution to your problem or just an error when pasting your code. int.Parse will not fail even when it is not assigned to any variable at all (since it can be used in a logical statement).
22 Sep 2013 by radnix
string addrStr = comboBoxIPaddress.Text.Substring(0, comboBoxIPaddress.Text.IndexOf(".")); //-here, we've taken the first digits up until the dot '.' // from the addr : ###.###.###.### is now first ### ex. 192.168.1.25 = 192 or 233.200.132.92 = 233 //- this will tell us if we are broadcast...
22 Sep 2013 by radnix
This is the Microsoft tutorial. Notice it does not use "Bind" (and runs fine on the same PC)UDP Listener:using System;using System.Net;using System.Net.Sockets;using System.Text;public class UDPListener { private const int listenPort = 11000; private static void...
23 Sep 2013 by radnix
OK, found a really great explination at:http://codeidol.com/community/dotnet/a-simple-udp-application/10474/[^]For connectionless communications, you must specify the Dgram SocketType, along with the Udp ProtocolType. Remember, if your application does not need to receive UDP data on a...
8 Mar 2017 by Member 13046160
HelloI want to send a data to the printer via udp port. I have a structure of that udp packet but have no idea how to build it.The structureDoes anyone have an idea?What I have tried:UdpClient udpClient = new UdpClient(); udpClient.Connect("192.168.0.99",...
8 Mar 2017 by Jochen Arndt
Create a C# structure that corresponds to the structure definition. This structure must not contain padding bytes (Pack = 1) and use members with fixed width (use byte, UInt16, UInt32 according to the length of the fields). See StructLayoutAttribute.Pack Field...
3 Jan 2012 by PeteBarber
A basic implementation of an NFS server in C#.
8 Jan 2018 by saide_a
I have a UDP connection that connects an echo server with a test client. test client continuously sends packets and waits about a second for receiving them. if it can't get the packet, assumes that packet is lost and sends another packet. Most of the packets are sent and received successfully...
8 Jan 2018 by Jochen Arndt
When using localhost (loopback), there should be no packets lost and no significant delay. So the problem may be sourced by your implementation (probably the server code that handles receiving). Network receiving code should be event driven running in an own thread. Then it can react...
8 Jan 2018 by KarstenK
As all wrote the use of TCP is in that case better. Another solution is to use UDP packets with a time stamp or counter in the payload, so you check which packets are to drop.
20 Nov 2018 by Engr.Shah
Hi there, still not mature in c# programming, i have written an application in which it receives data from arduino using UDP protocol, when i click a button data is sent and received without hurdle, but i want my application to receive data automatically when arduino sends it. so that i wont...
20 Nov 2018 by Afzaal Ahmad Zeeshan
You need to attach the async callback1, that receives the data for your socket, on its behalf and then alerts you that data has been received. You cannot attach a receive function, as it might be blocking. You can argue, that, // Your receive call is useless as well, and so would be this, ...
14 Nov 2011 by hoernchenmeister
Hello world,I am currently facing an ugly problem after our admin installed windows updates.We have a service running on a server in our local network.It registers itself on startup in a database, writing its ip and the number of a dynamically assigned port for UDP communication.Clients...
15 Nov 2011 by hoernchenmeister
Unfortunately our admin installed a virtual network adapter (Oracle Virtual Box) on all the Win 7 64bit machines together with the updates... So it wasn't obvious to spot the problem right away... Disabling the virtual network adapter did the job and everything started to work again.
18 Sep 2019 by Member 14589606
Only one reading can be taken from a sensor at a time. I used the concept of asynchronous sockets, that is, it is only reading the processor temperature of a single sensor at a time. When you add more, it shows that there is an error. Any ideas would be appreciated. After executing the jobs,...
18 Sep 2019 by OriginalGriff
Quote: The object reference was not set to an object instance This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable,...
18 Sep 2019 by Patrice T
Quote: Can only read one temperature reading from the processor of the sensor, for other sensors it does not work The usage of try/catch in your code prevent the program from telling you where the problem arise, and this is an important information. A try/catch is used to hide an error that you...
18 Apr 2019 by danger moose
Im trying to run a WCF service self hosted on visual studio that is able to send and recieve udp messages. The send works fine but I cant verify it using the recieve. What I have tried: Ive tried to recieve both from the same service and from an outside source on a different port but on the...
18 Apr 2019 by Gerry Schmitz
WCF Test Client (WcfTestClient.exe) | Microsoft Docs[^]
30 Apr 2013 by ayesha hassan
I have developed a udp application in which a single server is able to handle 'x' number of clients. Inside my server, there is a primary thread keeps on receiving requests/data continuously from the clients and keeps saving the information of each client in a list.As soon as a request comes...
30 Apr 2013 by skydger
It depends on how much clients do you expect and how large messages will be sent.The issue is that UDP does not guarantee delivery of data by itself, so some packets could be dropped.http://technet.microsoft.com/en-us/library/cc785220(v=ws.10).aspx[^]Simultaneous data sending both by...
20 Jun 2016 by Intel
Before you embark on a new Internet of Things project, you should consider which communication patterns are best suited to it.
10 May 2022 by Âu Quang Vũ
How can i connect client to server by using udp socket with java swing What I have tried: i dont know, ill tried but its only gonna get worse
10 May 2022 by Richard MacCutchan
Study the tutorials: Lesson: All About Sockets (The Java™ Tutorials > Custom Networking)[^]
9 Nov 2010 by David Knechtges
Not exactly certain of your questions, but I will answer given my use of the UDP protocol in my apps.I have a server and many clients on a LAN that use UDP for comms. The server broadcasts data to the clients every so often, and the clients also broadcast data to the server every so often....
9 Nov 2010 by hazem12
Hello all.I have a TCP/IP multithreading server /client application. i want to convert it to UDP protocol for testing performance issues.I have a question :As i found on UDP server i have one socket that send and recive data by using sendto and recivefrom but on TCP/ip you have a...
7 May 2013 by ayesha hassan
I have created 3 threads each thread has one socket each. Inside each thread, socket is made "Event Driven" and whenever data becomes available for reading, an event is generated.The code works fine but it takes CPU Usage upto 100% which is surely undesirable. I think I have made some...
7 May 2013 by KarstenK
i guess your threads are blocking the network api.why arent you making some outout or use your debugger...
7 May 2013 by Jochen Arndt
Did you report errors and terminate the thread when a function call fails?There is at least one wrong call that should result in an error return (best case) or undefined behaviour (worst case):WSAWaitForMultipleEvents(2, &hEvent, FALSE, WSA_INFINITE, FALSE);You are passing 2 for the...
14 Apr 2012 by Member 8416408
How to create a streamer in a Windows Console Application that outputs a struct on a specific port(lets say 1234)? I already have a working code in C# that uses UDPClient Class to listen to this stream.
14 Apr 2012 by Richard MacCutchan
Google for "C++ sockets" there are plenty of samples available.
22 Sep 2015 by neethujayan
Please help me to find solutionSERVER SIDE CODE Name :
25 Sep 2015 by ChauhanAjay
Kindly go through the following articleChat Application in PHP[^]Hope the above link helps.
29 Mar 2013 by ayesha hassan
I want two functionalities to be implemented on my udp server application. 1. Creating thread that continuously receives data coming from any client. 2. Creating a thread that continuously sends data on server socket after specific time period and waits for reply from client. (I implemented this...
29 Jun 2015 by Member 11499804
HelloMy program receives data from UDP (a packet of 414 byte data at a time, 400 times/sec)and writes the received data (414 bytes) into a text file using fprintf()and writes part of the data into image files using fprintf().In a threaded function, the UDP communication and file...
10 Dec 2013 by Member 10318167
Anybody got a working solution for sending and receiving data via UDP on Android using C#/Mono?I have a working UDP send/receive system on Windows Phone based on UdpAnySourceMulticastClient, but this is not supported in Mono. Forum trawling has led me to UdpClient, but I have not found any...
21 Jul 2015 by Member 11499804
Hello, I don't have much knowledge on communication protocols and I'm confused with: I observed that Wireshark capture is more robust (?) than C-application with CSocket (ReceiveFrom()) to receive UDP data.What factors make the difference? Is Wireshark doing some low-level tasks?Can...
21 Jul 2015 by Kornfeld Eliyahu Peter
Wireshark is an open-source tool, so you can get its code and learn it to understand, how exactly the goals are fulfilled...https://www.wireshark.org/[^]
21 Jul 2015 by User 59241
You have probably realised that you are starting to go around in circles. Wireshark uses pcap https://en.wikipedia.org/wiki/Pcap[^] which is a very low level packet sniffing API. It accesses the hardware directly and bypasses the TCP stack altogether. This makes it useful for diagnosing network...
23 Jul 2015 by Albert Holguin
Quote:I observed that Wireshark capture is more robust (?) than C-application with CSocket (ReceiveFrom()) to receive UDP data.Not more robust. If implemented correctly, your application should get every single packet wireshark gets.Quote:What factors make the difference? Is Wireshark...
30 May 2013 by ayesha hassan
I have developed a single Server/multiple Clients udp application, where Server can handle x number of clients at a time. The Server has x number of threads each thread dedicated to one Client.The code works perfectly fine. Now I want to check my application for all possible scenarios i.e....
2 Nov 2022 by CarlyJeps
Hello how can i fixes this error [Error] SFML/Network.hpp: No such file or directory The code: #include #include #include #include #include static bool port_is_open(const...
2 Nov 2022 by Richard MacCutchan
The message is clear, the compiler cannot find that file or directory. Assuming this is some third-party header, you need to provide the full path, or add its location to the compiler search path.
2 Nov 2022 by k5054
If the SFML code is in the current directory, then use #include "SFML/Network.hpp" When you use #include the compile only searches the System directories (e.g. /usr/include, /usr/local/include, some others specific to the compiler) and...
2 Nov 2022 by Rick York
Richard is correct. It is important to understand the difference between using angle brackets () and quotes with include directives. The quotes will look for files in the local directory first, which is where the source file is, and then in...
1 Apr 2015 by Member 11499804
HelloI want to ask some advice regarding my program.It is supposed to receive data packets, each with a size of 400 bytes. Transmit speed is 414 packets per second.But the stored data in ptr_logFile_hex (text file) omits some of data as1, 3, 5, 8, 10, ... (when packet number...
1 Apr 2015 by Richard MacCutchan
You should not use UDP for such an application, unless you include your own message checking. UDP[^] is not reliable, as messages can appear in any order and are not guaranteed to be delivered. If the data is important then you should be using TCP.
3 Jan 2014 by sharathkumar27
Issue With Below code is I'm unable to transfer whole file. If the file size 35kb. It'll only transfer 10 kb or 5 kb only. For Client Im using class FTClientCode { public static string curMsg = "Idle"; public static void SendFile(string...
3 Jan 2014 by Rob Philpott
I think this line is the problem:int receivedBytesLen = clientSock.Receive(clientData);In that I think you are expecting to receive the whole data sent in this single call. It doesn't work like that (I've been caught out myself with this). This will return the data in chunks as it is...
4 Sep 2014 by m.bleimuth
Hi experts,whats the best way to let a tcp client connect to an unknown tcp Server. That means i have multiple Clients in my Network and multiple Servers application, now i want that all Clients connect automatically to one of the servers. First i tried using UDP and broadcast the server...
4 Sep 2014 by DaveAuld
One option would be to make the clients go into a listen - sleep - wake - try port - listen cycle. Each client would wake up, try to bind to the udp port, if it fails (due to the port already being in use) go back to sleep again for a random duration. If it is able to bind to the port then...
20 Feb 2016 by Andy_N
Is is a small app with UDP & dataGridView.While first start Firewall ask confirmation for UDP and Form of app is white (w/o dataGridView). After that happens nothing. I have to close & start again and then works all properly.Thanks for help.AndyWhat I have tried:UDP Listener...
20 Feb 2016 by Maciej Los
I'd suggest to read this: Open a port in Windows Firewall - Windows Help[^]. If it won't help, you should provide more details, as Richard and Caroline have mentioned in the comments to your question.
4 Apr 2018 by Balaraj Nayak
How to fragments large data into small packets. since i am beginner i am unable achieve it, SOMEBODY HELP TO FRAGMENT LARGE DATA INTO SMALL PACKETS . say i have 22kb of jpeg file i want it to devide into small packets with 960 bytes of each. for jpeg there will be STARTING two bits and ENDING...
4 Apr 2018 by Jochen Arndt
Your code will not work because the image data might contain the JPEG markers too (here: the FF D9 end of image marker). So you have to write a parser that gets also the segment length for all non stand alone markers. When such a segment is processed, pass all bytes of the length without...
4 Apr 2018 by KarstenK
For sending over the network the splitting of the binary data is enough. If you want smaller jpeg than you must use higher compression or split the decompressed picture in sub pictures and than compress. The article CXImage shows these techniques.
13 May 2010 by kivanc.imer
Hello, I am trying to use connectionless async UDP listener.I need to get Remote Endpoint to use in processes and i can get remote Endpoint info with udpClient.EndReceive(ar, IP_Remote_End) command.But as you can see I am stopping the listener for a few milisecs.I lost a few packets in this...
10 May 2010 by DaveAuld
I haven't tried this, but;As the BeginReceive is non-blocking, and you have declared udpClient as instance variable, you should be able to access the underlying socket and remote endpoint from;udpClient.Client.RemoteEndpoint
13 May 2010 by Chris Kolkman
What you need is a "state" class you can pass along. This state class can hold a reference to the EndPoint passed to the UdpClient. I'm not sure how well the example holds up with BeginReceive (especially with calling it again to continue listening) as I've only really used BeginReceiveFrom -...