UdpClient (System.Net.Sockets.UdpClient) is a .NET-Class allowing to send and receive UDP-Traffic.
Questions tagged [udpclient]
575 questions
104
votes
2 answers
Why does sending via a UdpClient cause subsequent receiving to fail?
I'm trying to create a UDP server which can send messages to all the clients that send messages to it. The real situation is a little more complex, but it's simplest to imagine it as a chat server: everyone who has sent a message before receives all…

Jon Skeet
- 1,421,763
- 867
- 9,128
- 9,194
43
votes
5 answers
Can I set the timeout for UdpClient in C#?
I am wondering whether I can set a timeout value for UdpClient receive method.
I want to use block mode, but because sometimes udp will lost packet, my program udpClient.receive will hang there forever.
any good ideas how I can manage that?

Jack
- 3,913
- 8
- 41
- 66
27
votes
2 answers
Receive messages continuously using udpClient
I was looking for the best solution to receive and process messages via UdpClient class in C#. Does anyone have any solutions for this?

Saanch
- 1,814
- 1
- 24
- 38
25
votes
2 answers
Send and receive data on UDP Socket java android
I am able to properly send my data through UDP socket , but when I receive data it keeps on waiting at receive command I don't know what is causing this.
Please have a look at my code below.
I am able to properly receive data at server side from…

user2539602
- 618
- 3
- 9
- 18
22
votes
4 answers
How to set the source port in the UDP socket in c?
Can any one tell me how to set the Source port address in the UDP socket ?. My client application needs to send the Packets from the 57002 port to the server port 58007 .

Balamurugan
- 2,259
- 8
- 33
- 48
18
votes
2 answers
Error receiving in UDP: Connection refused
I am trying to send a string HI to a server over UDP in a particular port and then to receive a response. However, after I try to get the response using recvfrom() I was stuck in blocking state. I tried using connected UDP but I got:
Error…

sfactor
- 12,592
- 32
- 102
- 152
15
votes
4 answers
Connecting two UDP clients to one port (Send and Receive)
I tried the suggestion from this question with very little success.
Please... any help will be greatly appreciated!
Here is my code:
static void Main(string[] args)
{
IPEndPoint localpt = new IPEndPoint(IPAddress.Any, 6000);
UdpClient…

brooc
- 448
- 2
- 6
- 10
15
votes
4 answers
Broadcasting UDP message to all the available network cards
I need to send a UDP message to specific IP and Port.
Since there are 3 network cards,
10.1.x.x
10.2.x.x
10.4.x.x
when i send a UDP message,i am receiving the message only in one network adapter...the rest of the ip's are not receiving.
I want to…

Anuya
- 8,082
- 49
- 137
- 222
13
votes
4 answers
What is the size of udp packets if I send 0 payload data in c#?
I have figured out the maximum data before fragmentation between 2 endpoints using udp is 1472(other endpoints may vary). This states that mtu is 1500bytes and header overhead per packet is 28bytes. Is it safe to assume that if I send 0 bytes data…

Syaiful Nizam Yahya
- 4,196
- 11
- 51
- 71
11
votes
1 answer
How to specify source port of a UdpPacket?
I wanted to send UdpPacket to a specific remote host (I already know the public IP and Port).
I wanted to use C#'s UdpClient class.
static int Main()
{
UdpClient client = new UdpClient();
IPEndPoint remoteEP = new…

raisyn
- 4,514
- 9
- 36
- 55
10
votes
1 answer
C# UDP client reading multicast IP (local interface), and sending unicast UDP to VPN
I have a VPN client that works fine for sending unicast UDP packets over the VPN pipe but does not do that for multicast IP (UDP) packets (OpenVPN). So I thought I could write this little shim that would take the IP (port 3000) multicast and send…

Dr.YSG
- 7,171
- 22
- 81
- 139
10
votes
5 answers
How to use UdpClient.BeginReceive in a loop
I want to do this
for (int i = 0; i < 100; i++ )
{
Byte[] receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
}
But instead of using UdpClient.Receive, I have to use UdpClient.BeginReceive. The problem is, how do I do that? There…

Syaiful Nizam Yahya
- 4,196
- 11
- 51
- 71
8
votes
3 answers
How to know the port number used by c# UdpClient?
I am creating a client server application using c sharp. The server is using tcplistener with fixed port number. the client connect to the server using tcpclient. Once connected, both client and server communicate using this connection. The…

Syaiful Nizam Yahya
- 4,196
- 11
- 51
- 71
8
votes
2 answers
Socket has no attribute AF_INET?
I am trying to do a socket programming assignment from one of my textbooks.. UDP connection..
UDPServer.py
from socket import *
serverPort = 12000
serverSocket = socket(AF_INET, SOCK_DGRAM)
serverSocket.bind(('', serverPort))
print('The server is…
user3476554
8
votes
1 answer
Cause of high UDP package loss on localhost?
In my WPF 4.0 application, I have a UDP listener implemented as shown below. On my Windows 7 PC, I'm running both server and client on localhost.
Each received datagram is a scanline of a larger bitmap, so after all scanlines have been received the…

l33t
- 18,692
- 16
- 103
- 180