udpclient

What is the drawback if I do not invoke the UdpClient.Close() method?

耗尽温柔 提交于 2019-12-08 05:09:47
问题 I have the following code block, and it affects my program efficiency. The problem here is if the target host exists, everything is OK. But if it does exist, it takes too long to execute. Finally, I found out the "udp.Close()" occupies the most of execution time. If I does not invoke the close method, the efficiency is good. Can anyone help me tell me what is the drawback if I do not invoke the close method?? Thank you very much. { // This is my code block, I need to execute it many many

How do I know if UdpClient has been closed/disposed?

﹥>﹥吖頭↗ 提交于 2019-12-07 10:29:30
问题 I am receiving data from UdpClient via the usual async callback: private void OnUdpData(IAsyncResult result) { byte[] data = _udpReceive.EndReceive(result, ref _receiveEndPoint); //Snip doing stuff with data _udpReceive.BeginReceive(OnUdpData, null); } When I Close() the UdpClient in the main thread, the callback fires as I would expect, but at this point _udpReceive is already disposed and I get an ObjectDisposedException when I try and call EndReceive() . I was expecting to just get an

Sending UDP packets over the Internet

[亡魂溺海] 提交于 2019-12-07 08:07:53
问题 I'm trying to learn some of the ins and outs of P2P/decentralized networks. My question is the following. Say I have two machines named comp1 and comp2. Now comp1 is setup on my home network behind a router, and comp2 is located in my office at also behind a router. Is it possible for me to send UDP packets back and forth across the Internet like this assuming of course that ports are forwarded properly? To offer more insight on what I'm investigating, I'm trying to figure out how a new node

UDPClient Multicast receive fails on computer with multiple NICs

馋奶兔 提交于 2019-12-07 05:09:43
问题 I've got a computer with multiple NICs - and UDPClient's send method continually fails. Here's the code: private static void receiveData() { recvSock = new UdpClient(PORT); //recvSock.Client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, mainInterface); recvSock.JoinMulticastGroup(IPAddress.Parse(IP), 50); IPEndPoint iep = new IPEndPoint(IPAddress.Any, 0); while (true) { byte[] data = recvSock.Receive(ref iep); // Do not include messages from us if (myIPs.Contains

What is the drawback if I do not invoke the UdpClient.Close() method?

坚强是说给别人听的谎言 提交于 2019-12-06 15:41:45
I have the following code block, and it affects my program efficiency. The problem here is if the target host exists, everything is OK. But if it does exist, it takes too long to execute. Finally, I found out the "udp.Close()" occupies the most of execution time. If I does not invoke the close method, the efficiency is good. Can anyone help me tell me what is the drawback if I do not invoke the close method?? Thank you very much. { // This is my code block, I need to execute it many many times. string ipAddress = Dns.GetHostAddresses("joe-pc").FirstOrDefault().ToString(); UdpClient udp = new

C# UDP Proxy / Pipe

99封情书 提交于 2019-12-06 14:56:14
问题 Any example design code in C# or VB.NET ? Looking for a UDP Pipe example in .NET I downloaded Simple UDP proxy/pipe 0.4.1 by Luigi Auriemma Which is in C++.. it works perfectly.. but I want to make my own implemention in .NET.. so I can sniff packets directly. 回答1: Fixed it here is the solution if anyone wants to learn how I fixed it.. Please note this is probably the only UDP Proxy on all of google if you stumbled upon this.. that is coded in C#.. easily ported to VB.NET with online .NET

how can I parse a UDP packet in .NET?

我们两清 提交于 2019-12-06 08:37:52
how can I parse a UDP packet in .NET? I'm using PCap.Net to capture packets, in this case UDP packets, which I can access from the PCap.net object via (PcapDotNet.packets.Ethernet.IpV4.Udp). How can I take the results, the Udp packet, and parse this? In particular to unbundle DNS requests and responses that occur that are housed within a UDP packet. Is there a library that could help here? EDIT : To be more specific what I want to be able to do is extract the IP address from the DNS response, and based on examination using Wireshark it would be by: (a) Input: Payload of a UDP packet that is a

DatagramSocket cannot receive data from UdpClient

♀尐吖头ヾ 提交于 2019-12-06 06:46:05
问题 I am making an Win RT app that connects to a desktop app and they start to communicate in UDP and TCP. I have successfully implemented TCP communication in that I can send from Win RT to Desktop and send from Desktop to Win RT. using StreamSocket on Win RT and TcpListener on desktop. I also made it to send Udp data from Win RT to desktop without any problem. But I can't receive data's sent from desktop to Win RT. I use the following code and I don't see any problem with that but there must

SocketException An existing connection was forcibly closed by the remote host

一曲冷凌霜 提交于 2019-12-06 06:32:01
问题 I've decided to take a look at network messaging etc and my first port of call was UDP. The problem i have is when i attempt to send a message. I'm trying to hit an IP on a specifc port, but the application errors with the error "SocketException An existing connection was forcibly closed by the remote host". Here is the code. User ME = new User(); UdpClient MyUDPClient; private void Form1_Load(object sender, EventArgs e) { ME.Username = Environment.UserName; } private void StartUDP_Click

recvfrom() not filling the from IP address even for UDP messages in first call

荒凉一梦 提交于 2019-12-06 05:47:41
问题 I am using recvfrom() to get the UDP datagram into my buffer and passing non-NULL from_addr structure & len argument expecting it to get the source IP. But for the first call, they are NULL. Subsequent calls are filling the addr structure and len field. Is this expected ? #include <stdio.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> int main() { struct sockaddr_in myaddr, from_addr; char from_ip[1024] = "", myip[2014] = ""; char rmsg[1024 * 1024