Ethical Hacking Institute Course in Pune-India
Extreme Hacking | Sadik Shaikh | Cyber Suraksha Abhiyan
This article describes a very basic one-way Client and Server setup where a Client connects, sends messages to server and the server shows them using socket connection. There’s a lot of low-level stuff that needs to happen for these things to work but the Java API networking package (java.net) takes care of all of that, making network programming very easy for programmers.
Client Side Programming
Establish a Socket Connection
To connect to other machine we need a socket connection. A socket connection means the two machines have information about each other’s network location (IP Address) and TCP port.The java.net.Socket class represents a Socket. To open a socket:
Communication
To communicate over a socket connection, streams are used to both input and output the data.
Closing the connection
The socket connection is closed explicitly once the message to server is sent.
In the program, Client keeps reading input from user and sends to the server until “Over” is typed.
Java Implementation
Establish a Socket Connection
To write a server application two sockets are needed.
Communication
getOutputStream() method is used to send the output through the socket.
Close the Connection
After finishing, it is important to close the connection by closing the socket as well as input/output streams.
Important Points
To run on Terminal or Command Prompt
Open two windows one for Server and another for Client
1. First run the Server application as ,
Server started
Waiting for a client …
2. Then run the Client application on another terminal as,
It will show – Connected and the server accepts the client and shows,
Client accepted
3. Then you can start typing messages in the Client window. Here is a sample input to the Client
Which the Server simultaneously receives and shows,
Notice that sending “Over” closes the connection between the Client and the Server just like said before.
If you’re using Eclipse or likes of such-
www.extremehacking.org
Cyber Suraksha Abhiyan , CEHv9 , CHFI , ECSAv9 , CAST , ENSA , CCNA , CCNA SECURITY , MCITP , RHCE , CHECKPOINT , ASA FIREWALL , VMWARE , CLOUD , ANDROID , IPHONE , NETWORKING HARDWARE , TRAINING INSTITUTE IN PUNE , Certified Ethical Hacking , Center For Advanced Security Training in India , ceh v9 course in Pune-India , ceh certification in pune-India , ceh v9 training in Pune-India , Ethical Hacking Course in Pune-India
crate and barrel cc bealls cc