I created 2 files Client.java and Server.java and i tried to send the data using sockets to Server side and display it.
But I am getting a Run-time exception.
The code along with the output(within comments) is displayed below.
I see a couple of obvious problems here. First, neither of these lines:
will compile, as the first line has that extra comma, and in the second, the "int" returned by read() can't be assigned to s1, which is a String. So you're not showing us the actual code which caused the error; that makes it harder to diagnose the problem!
But in any case, I think what's happening is that your client writes to the socket and exits without closing the connection properly. Output buffered on the client side can get dropped without being sent, and indeed, the connection can simply disappear from the server's perspective, which could give the "Connection reset" error. You need to explicitly close "out" in the client when you're done with it:
The link Ulf gives is a good one, although it probably won't matter until you try to use sockets to connect from one platform to another. In this toy program on one machine, it won't be a problem.