문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top