Search code examples
javasocketssocketserver

Which protocol does Java's Socket use?


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.


Solution

  • 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.