Java Sockets

suggest change

Versions

java.net sockets have been in Java since 1.0. The original version list named Java SE 1.2, 6, 7, and 8.

Introduction

Sockets are a low-level network interface for a connection between two programs, often a client and a server, which may or may not be running on the same machine.

Socket Programming is one of the most widely used networking concepts.

Remarks

There are two types of Internet Protocol Traffic -

1. TCP - Transmission Control Protocol
2. UDP - User Datagram Protocol

TCP is a connection-oriented protocol.

UDP is a connectionless protocol.

TCP is suited for applications that require high reliability, and transmission time is relatively less critical.

UDP is suitable for applications that need fast, efficient transmission, such as games. UDP’s stateless nature is also useful for servers that answer small queries from huge numbers of clients.

In simpler words -

Use TCP when you cannot afford to lose data and when time to send and receive data doesn't matter.
Use UDP when you cannot afford to lose time and when loss of data doesn't matter.

TCP delivers the bytes of a connection in order. It does not guarantee that a connection stays up, so data can still be lost if the connection fails.

UDP does not guarantee that a datagram arrives, or that datagrams arrive in order.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents