Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Java client server socket program

Thread view: 
nish - 08 Apr 2007 23:04 GMT
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
SadRed - 09 Apr 2007 03:11 GMT
> Hello friends,
>                    I need your help to  solve the socket programming
[quoted text clipped - 6 lines]
>
> Nish

See: http://java.sun.com/docs/books/tutorial/networking/sockets/index.html
soumya547@gmail.com - 10 Apr 2007 07:38 GMT
> > Hello friends,
> >                    I need your help to  solve the socket programming
[quoted text clipped - 8 lines]
>
> See:http://java.sun.com/docs/books/tutorial/networking/sockets/index.html

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();

}
}
Andrew Thompson - 10 Apr 2007 08:25 GMT
..
(nish)
>> > ..socket programming
..
(SadRed)
>> See: http://java.sun.com/docs/books/tutorial/networking/sockets/index.html
>
>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?

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.