7

I'm getting started with Java's Socket and SocketServer classes.

As mentioned above I would like to know which protocol (or however it is called) the Socket classes are using to communicate by default.

It is probably TCP, but I couldn't find anything specific, probably I'm overlooking something.

3 Answers3

15

Yes, Socket and ServerSocket use TCP/IP.

The package overview for the java.net package is explicit about this, but it's easy to overlook.

UDP is handled by the DatagramSocket class.

erickson
  • 265,237
  • 58
  • 395
  • 493
4

As stated in this oracle documentation post sockets play with TCP. Many people mistakenly suppose that Socket class handles UDP too, but UDP are handled by the DatagramSocket class

Hope I helped!

Pantelis Natsiavas
  • 5,293
  • 5
  • 21
  • 36
0

Java Socket use TCP/IP, read this when you're beginner

http://www.javaworld.com/article/2077322/core-java/sockets-programming-in-java-a-tutorial.html

kris14an
  • 741
  • 7
  • 24