udp

[Java] Listening on UDP socket

Hey everyone, I am using this code to receive data from a UDP socket and return it as string: byte[] receiveData = new byte[MAX_PACKET_SIZE]; DatagramPacket receivedPacket = new DatagramPacket(receiveData, receiveData.length); serverSocket.receive(receivedPacket); return new String(receivedPacket.getData(), 0, receivedPacket.getLength(...

Maximizing performance on udp

hey. im working on a project with two clients ,one for sending, and the other one for receiving udp datagrams, between 2 machines wired directly to each other. each datagram is 1024byte in size, and it is sent using winsock(blocking). they are both running on a very fast machines(separate). with 16gb ram and 8 cpu's, with raid 0 drives. ...

Identify C++ Socket port number

Ok, so I can create a socket and send a message to a remote machine (UDP btw). My problem is that I need to know what port I sent the message on. The remote machine is going to respond on the same port that I sent from. Right now it seems to be picking random high ports, like 46555. Is there a way to specify what port it goes out on or i...

Passing http form values to a C program

I've been assigned to upgrade an embedded application written in C. The application is configured via a web interface. When the user modifies the web application a file is written to /var/www/settings.json and the file /var/www/UPDATE_SETTINGS is touched. In the main application loop it checks to see if UPDATE_SETTINGS exists. If it do...

How do I connect to a UDP port in Python?

Like everyone else, I can say "I've tried everything!" I kind of did. I looked all over StackOverflow, and tried all the answers, but got nothing. Anyways, I am jetting to at least get some code printed by Python before I get even further in developing this. I want to receive UDP packets from my Garry's Mod server (logaddress_add MyIP:7...

Sending UDP packets on iPhone fails over a fresh new 3G connection, but works otherwise

I'm having a strange problem when sending UDP packets from an iPhone over a 3G. Almost every time my application starts after a longer period of network inactivity (for instance after the phone comes from the sleep mode or it just gets a 3G connection), my application is not able to send any UDP packets. I get a kCFSocketError error stat...

UDP recvfrom call returns wrong port number. Why?

Im playing with 'recvfrom' and 'sendto' calls using UDP. I have a client that just broadcast UDP packets on port 6000. I have a server that binds a socket on port 6000, and do a single recvfrom. The problem is that sin_port member of struct sockaddr returned from recvfrom is always incorrect. Why? I would post some source code but some...

Getting the socket FD from IP address and port

Is their a way (except looping on all open FDs) to obtain the FD for a given IP addr & port? I have a bunch of open UDP sockets each bound to an IP address & port. The application, in some instances, acts as a forward application. Is their a getfdbyname system call? Specifically, my UDP application(C) sits between nodes A and B . 1) A...

StringBuffer doesn't append data - due to thread?

Hello, my target is it to collect data from clients which send data to an UDP server, concatenate the data in a string (just for testing now) and send the whole concatenated string back to the client. The communication between UDPClient and UDPServer works perfect. I can send data and receive it. But I wonder why I can't concatenate the...

Sending char pointer with UDP in C

I have a struct that I am sending to a UDP socket: typedef struct { char field_id; short field_length; char* field; } field_t, *field_p; I am able to read the field_id and field_length once received on the UDP server-side, however the pointer to field is invalid as expected. What is the best method to properly send and re...

Does boost have portable way to use ntohl/htonl/ntohs/htons type functions?

I am using UDP in particular boost::asio::ip::udp::socket sockets if that helps? What is the header file? What headers/classes do I need to handle network byte ordering with the UDP under boost? ...

When will one socket suffice, when do I need to create more?

The "connectionless" aspect of UDP has thrown me for a loop... If I setup a UDP socket set to INADDR_ANY, then bind that to port 33445 on the local machine, the machine will accept incoming connections from various clients. All of these connections will be serviced by that one socket, since this is not TCP and I cannot spawning a new c...

native UDP implementation for android

I'm trying to use native implementation of UDP server/client on Android, I'm using JNI to access the native code from java. The code was tested successfully on Android 1.5 (HTC Hero) but when I tried to run the same application on Android 2.1 (HTC Legend) I got "Stack Corruption Detected" every time I received a packet bigger than 32 by...

How to make a UDP socket replace old messages (not yet recv()'d) when new arrive?

Hello everybody! First, a little bit of context to explain why I am on the "UDP sampling" route: I would like to sample data produced at a fast rate for an unknown period of time. The data I want to sample is on another machine than the one consuming the data. I have a dedicated Ethernet connection between the two so bandwidth is not an...

Sending from the same UDP socket in multiple threads

I have multiple threads which need to send UDP packets to different IP addresses (only to send, nothing needs to be received). Can I reuse the same UDP socket in all the threads? ...

Sending UDP packets via Java

Hi all, I'm trying to send UDP packets from my PC to an FPGA via my laptop's ethernet cable. I've been using Java's DatagramPacket and DatagramSocket to send the UDP packets. However, these packets will only send over my laptop's wireless interface. How can I specify that the packets should go through my ethernet interface? Thank you. ...

Nice book/tutorial about using UDP in objective c?

Hey, I wanna make a MMORPG, I'm now working on the multiplayer. The client is iOS device, so I'll use objective c on the server too. I'm googling for hours and can't find a nice tutorial to use the UDP for begginers. Also is obj-c on the server is a good idea? Oh, and other thing.. What is "Socket"? Thanks! ...

Example of using UDP in obj-c/C++?

Hey, I'm making an iOS app - real-time game, wanna use UDP protocol. I'm searching a lot for examples/guides, but can't find any. Also, the software on the server will use C++, and I've searched a lot and can't fina a nice way to use it, for begginers in C++... I found that: http://developer.apple.com/mac/library/samplecode/PictureShar...

UDP hole punch possible?

I'm trying to see if UDP hole punching is possible behind a certain NAT, but I've found that when the computer behind the NAT sends out UDP packets to two different IPs to the same port while being bound to the same port, the NAT assignes two different external port numbers. So behind this particular NAT, I believe UDP hole punching is i...

UDP malformed packets

I use C# program for client UDP application. Application listens for a connection, and then communicates. Socket udpClient = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); udpClient.Bind(new IPEndPoint(IPAddress.Any, ListenPort)); udpClient.Blocking = true; int count = 0; while (count == 0) udpClient.Recei...