This repository is a collection of Java examples and exercises to demonstrate the basics and practical use of socket programming in Java. It includes code samples and explanations for creating both client-server and peer-to-peer network applications using Java's networking libraries.
- Examples for both TCP and UDP socket communication
- Simple chat application using sockets
- File transfer between client and server
- Handling multiple clients with multithreading
- Clear, well-documented sample code for learning and experimenting
-
Clone this repository:
git clone https://github.com/j-ordanos/Java-socket-programming.git cd Java-socket-programming -
Compile the Java files:
javac src/*.java -
Run the example programs:
java src.Server java src.Client
(Replace
ServerandClientwith the actual class names as needed.)
- Java JDK 8 or higher
- Echo server and client
- Multi-client chat server
- File transfer with sockets
- UDP datagram exchange
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.