31-07-2012, 11:23 AM
LAN Chat server
Networking (java.net)
Network Socket
Allows a single computer to serve many client at once
As well as serving different information also
This is managed by port
Port
Numbered socket on a particular machine
Multiple client can connect on same port
Imaginary points
TCP/IP reserves the lower 1024 ports
21 for FTP,23 for Telnet, 25 for email, 80 for HTTP
Socket Basics
A socket is a connection between two hosts.
It can perform seven basic operations:
• Connect to a remote machine
• Send data
• Receive data
• Close a connection
• Bind to a port
• Listen for incoming data
• Accept connections from remote machines on the bound port
Client vs. Server
Traditional definition
- Client: user of Network Services
- Server: Supplier of Network Services
Analogy: Company phone line
Installing phone is like starting server
Extension is like port
Person who calls is the client : he specifies both host(general company number) & port(extension)
Working :
Formation of socket to make a connection with the server
Server will forward the request to specific client by making a socket connection with client
For voice transfer client side data will be stored in rm format for 2-3 seconds
Then it will be forwarded towards receiving client where it will be played
This process of voice transfer will continue in a loop
Using streams we can transfer any type of data