Coursework project for Concurrent Programming (UCM), 2024–2025. A client–server directory plus peer-to-peer (P2P) image transfer system built with Java, TCP sockets, and a Swing GUI.
- Alejandro Parreño Minaya — @aparreno14
- Diego Ostos Arellano
- Clients connect to a central server to register and publish a list of available images.
- When a client requests an image, the server matches requester ↔ owner.
- The actual file is transferred directly between clients (P2P) over TCP.
-
Listens on a fixed TCP port (see
src/server/Server.java). -
Maintains:
- active users and their published image lists
- input/output streams per user
-
Spawns dedicated listener threads to handle multiple clients concurrently.
-
Provides a Swing GUI to display connected users and server logs.
-
Swing GUI client.
-
Talks to the server for:
- registration
- listing available images
- requesting an image
-
For P2P transfers:
- Emitter opens a temporary TCP port and serves the requested file to the peer.
- Receiver connects to that temporary port and downloads the image.
The system uses a custom message protocol (serializable objects) with message kinds such as:
CONEXION/CONF_CONEXIONLISTA_PRODUCTOS/CONF_LISTA_PRODUCTOSPEDIREMITIRPREPARADO_CS→ server (emitter announces P2P port)PREPARADO_SC→ requester (server forwards P2P port)IMAGEN_NO_EXISTECERRAR_CONEXION/CONF_CERRAR_CONEXION
This project expects local folders under data/:
- Images you want to share should be placed under:
data/<userId>/ - Downloaded images are saved under:
data/<userId>/descargas/
Tip: create those folders for each user you test with.
This project was developed with Windows + Eclipse.
-
Import the project in Eclipse (existing project from filesystem).
-
Run the server:
- Run
src/server/Launcher.java(starts the GUI + server loop).
- Run
-
Run two clients (in separate runs):
- Run
src/cliente/Cliente.javatwice.
- Run
-
Use the GUI to:
- connect/register with different
userIds - publish images (by placing files in
data/<userId>/) - request an image from the global list and download it via P2P
- connect/register with different
Notes:
- Local testing assumes
localhost. - Make sure your firewall allows local TCP connections (server port + temporary P2P ports).
src/server/— server logic + GUIsrc/cliente/— client GUI + P2P emitter/receiver threadssrc/mensajes/— message classes and enumssrc/tablas/— shared tables (users/streams/products) with concurrency controlsrc/semaforos/,src/locks/— synchronization primitives used by the tables
GPL — see LICENSE.
This is an educational project developed for a university course.