udp

Why does TCP work, when UDP does not?

The code: <?php error_reporting(E_ALL); /* Allow the script to hang around waiting for connections. */ set_time_limit(0); /* Turn on implicit output flushing so we see what we're getting * as it comes in. */ ob_implicit_flush(); $address = '127.0.0.1'; $port = 11100; if (($sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UP)) === fals...

UDP write to socket and read from socket at the same time

Server: <?php error_reporting(E_ALL | E_STRICT); $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_bind($socket, '127.0.0.1', 11104); $from = ""; $port = 0; socket_recvfrom($socket, $buf, 12, 0, $from, $port); //$buf=socket_read($socket, 2048); echo "Received $buf from remote address $from and remote port $port" . PHP_EO...

UDP write to socket and read from socket at the same time(again with modification)

Server: <?php error_reporting(E_ALL | E_STRICT); $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_bind($socket, '192.168.1.7', 11104); $from = ""; $port = 0; socket_recvfrom($socket, $buf, 12, 0, $from, $port); //$buf=socket_read($socket, 2048); echo "Received $buf from remote address $from and remote port $port" . PHP_...

How do I get sender's UDP port in C ?

I have the following typical code in C under Linux to get UDP data: sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); mysock.sin_family = AF_INET; mysock.sin_addr.s_addr = INADDR_ANY; mysock.sin_port = my_port; bind(sock, &mysock, sizeof(mysock); recvfrom(sock, buf, PKTSZ, 0, &client, len); All the above code works, but now I have a ne...

Best client/server UPD and TCP debugging tool?

I'm trying to find a simple TCP/UDP debugging tool. The tool should act like a client or a server, display incoming messages, allow sending messages, etc. Ideally, the tool would have a GUI and be extremely easy to use. For the life of me I can't find anything adequate. All tools I tried either truncate messages, inject dummy messages i...

UDP, NAT and setting up "connections"

I know the word "connection" isn't really appropriate when talking about UDP, but... How does a server (the one with the known IP) get its UDP packets through the Internet to a client that is behind NAT? For example: say a client connects and authenticates to the server using some messaging over TCP. At this point the server is ready t...

Broadcasting

Could anyone please provide me with the code or link to send and receive broadcast messages if possible using UDP? I have been stuck in a problem and hope if u guys could help me resolve it. Thanks ...

Reliable UDP

How can I develop a Linux kernel module in order to make UDP reliable? This is my college assignment and I don't how to proceed. how to do change the default UDP behaviour in linux kernel by loading a new kernel module? and how to program such kernel module? ...

Calculating number of bytes in C# UdpClient.Send() datagram

In C#, in order to use the UdpClient.Send() method I must provide as one of the parameters the number of bytes I am sending. How do I calculate the number of bytes in a datagram before sending it? ...

Udp Receiving

In c# I am using the UdpClient.Receive function: public void StartUdpListener(Object state) { try { udpServer = new UdpClient(new IPEndPoint(IPAddress.Broadcast, 1234)); } catch (SocketException ex) { MessageBox.Show(ex.ErrorCode.ToString()); } IPEndPoi...

Replying to a client over sockets (UDP) from a different process

I have a server than is a "command handler" process. It receives messages over UDP, and delegates the work to do to a different process by communicating to that process through it's published API (whatever IPC mechanism that process employes). Our system has several cooperating processes. The result of that API call is then then sent ...

To send an image every 50 ms., should I use TCP or UDP?

I am building a C# application, using the server-client model, where the server is sending an image (100kb) to the client through a socket every 50ms... I was using TCP, but besides the overhead of this protocol, sometimes the client ended up with more than one image on the socket. And I still haven't though of a clever mechanism to sp...

[JAVA] how to send multiple data in 1 single UDP datagram?

hi all, i'm working on a network programming assignment about writing a simple IM system (pretty much like the simplest version of windows messenger). the spec specifies that i must send over 4 fields of data in a single datagram packet, those are: To From Type Message where type refers to message type, implemented as a user defined enu...

How can I implement a threaded UDP based server in Java ?

How can I implement a threaded UDP based server in Java ? Basically what I want, is to connect multiple clients to the server, and let each client have his own thread. The only problem is, that I don't know how to check if a client is trying to connect to the server and spawn a new thread for it. boolean listening = true; System.out.p...

Confusion about UDP/IP and sendto/recvfrom return values

I'm working with UDP sockets in C++ for the first time, and I'm not sure I understand how they work. I know that sendto/recvfrom and send/recv normally return the number of bytes actually sent or received. I've heard this value can be arbitrarily small (but at least 1), and depends on how much data is in the socket's buffer (when reading...

Transfer a file through UDP in java

I have the following algorithm implemented in Java which uses TCP/IP: -Client request a file -Server checks if the file exists - if do: send contents of the file to the client - if not: send "file not found" msg to the client Now I`m having trouble implementing that using UDP Datapackets. Here is my code: CLIENT: package br.c...

What should i know about UDP programming?

I don't mean how to connect to a socket. What should I know about UDP programming? Do I need to worry about bad data in my socket? I should assume if I send 200bytes I may get 120 and 60 bytes separately? Should I worry about another connection sending me bad data on the same port? If data doesnt arrive typically how long may I (typ...

Problems testing UDP code outside of LAN?

I am learning udp in the next few days. This weekend i am going to be in one of those 72hour competition and i would like to have my UDP code work online by the end of it. During the competition i wont have any internet (so no calling someone and having them test). I know of some of the problems about UDP like packets coming in twice, ...

UDP broadcast and unicast through the same socket?

I have a Linux application that opens a UDP socket and binds it to a port. I haven't had any problem sending unicast packets through the socket. I had occasion to send a broadcast packet, so I enabled SO_BROADCAST, which allowed the broadcast packets to pass, but then I noticed that the unicast packets were being broadcast as well. Is...

How do i get a free socket port? C++

I am writing a UDP test client/server and i want to get it through firewall. Supposedly all i need to do is have both sides send to the correct IP and server. Getting an IP is not a problem but how do i have the client pick a random free port and report it to the user? I eventually would want it to connect to a matchmaker server but righ...