Hi friends, welcome to Tutor's funny channel. Today I am going to teach Java Networking
Programming class step by step. This is the Java Network Programming second class. First
class we saw how to find the IP address of the machine. Those who have not watched that
please watch that tutorial. This is the second Java Network Programming step by step tutorial
In this tutorial I have created two applications, client and server architecture. First I am
going to show the demo first. First I am going to run the server. So right click, run
file. Now the server is now listening the client request. What is the client request
coming from? After that I am going to select this one, client program. I am going to run
the client program. Now here server and client is connected. Server is now connected. Client
is now connected with server. Message will be displayed. Good morning Raja. Now I am
going to show you how this program works. This is the server socket programming. This
is very important stuff when you are making the chat application in Java. Very crucial
part of the Java programming is networking. You must study this one. If you are going
to master in Java, this is a must thing. You are mastering in Java. So here first I have
created the class server. This relevant name you have to implement it. Java.io package
and .net. .net stands for networking. If you are going to implement the network class
you must implement this name main space above. Java.net. Very simple one. Don't worry about
this. All the code part I have attached in my tutor's website. Don't worry about that
First I have created the object of the server socket class socket1. After that I have created
the constructor of the class server. Inside the constructor I have put the port. This
is the client request port. Create the server socket class object. This is the server socket
object. This is the accepting the connection from the client port which is a 2000. First
we have to connect with the server. It is now listening for the client. This is the
first time we are listening the client. After that when the request is coming from the client
it accepts the request here. It will be accept the request. Here I will be reading. I have
created the buffer reader object and it will be reading and print out the message here
Good morning client message. What is the client message coming from there? It is printing
here. That is the stuff done by server. Very simple. First it will be invoking the client
listening when you run the program. After that what is the request coming from the client
it accepts the request. This method I have written for accept method. After that we have
to print it here. Good morning it accepts the request. What is the request coming here
Accepted it is printing. This is printing here. That is the stuff we have to do. Let's
look at the concept of client. This is the same thing. It is a localhost. We have to
put localhost. It is a localhost 200 port. The same port should be there here. Same port
it is receiving. Here now client is connected with the server. Now here this is the buffer
reader. This is the message coming from the client side. Now it is printing the message
That is the stuff we have done here. Don't worry about the full coding I have attached
in my video description. How to write this program? Very simple one. The same package
I have created two classes. Client and server classes. Very simple here. This is all the
stuff we have to do. Very simple we have done. Same package we have created two classes
So first we have to run the server first. After that you have to run the client first
The same code you just copy and paste and run in your NetBeans program. Don't worry
about the full code I have attached in my video description. Thank you for watching
If you like my channel please subscribe me, like me. Thank you for watching