Java client server socket program

N

nish

Hello friends,
I need your help to solve the socket programming
question


Q write a client program that when a client connects to a server the
server returns the word of the day to the client


looking for your suggestions

Nish
 
S

soumya547


for that you have to write two programs like this..
server program :


import java.net.*;
import java.io.*;
public class servereg{
public static void main(String s1[])throws IOException{
ServerSocket s=null;
Socket con=null;
PrintWriter pr=null;
BufferedReader br=null;
try{
s=new ServerSocket(5000);
con=s.accept();
}catch(Exception e){
e.printStackTrace();}
pr=new PrintWriter(con.getOutputStream());
br=new BufferedReader(new InputStreamReader(con.getInputStream()));
String msg;
while((one=br.readLine())!=null){
System.out.println("msg:"+one);
}
con.close();

}
}
 
A

Andrew Thompson

(e-mail address removed) wrote:
..
(nish)
..
(SadRed)

for that you have to write two programs like this..
server program :

What makes your code better than the examples linked
from the URL that was listed by SadRed?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,082
Members
48,773
Latest member
Kaybee

Latest Threads

Top