Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(How) can I use ServerSocket to listen for UDP instead of TCP traffic?

Tags:

java

sockets

In my application, there's a module that uses ServerSocket to listen for incoming TCP connections. When I switched a client to use UDP, I expected to receive data anyway, but I was wrong. When I looked at the documentation, however, I couldn't find any config option to set up the socket for UDP. Do I have to use a different class?

like image 313
Hanno Fietz Avatar asked Oct 29 '10 12:10

Hanno Fietz


1 Answers

Use DatagramSocket. For a tutorial, look here http://download.oracle.com/javase/tutorial/networking/datagrams/index.html

like image 94
Samuel Avatar answered Nov 10 '22 01:11

Samuel