Article View: borland.public.jbuilder.java.language
Article #7659Chat applet
From: Russell
Date: Mon, 04 Jun 2001 03:40
Date: Mon, 04 Jun 2001 03:40
58 lines
2586 bytes
2586 bytes
Hi all , i am using RedHat6.1 , jbuilder3.5 and jdk1.3.
I have the code below for my server :
Hi all ,
I am using RedHat6.1 , jdk1.3 and jbuilder3.5. I am developing a
chat applet, however without any success.
I am execute the client app then the server apps. However the
server apps always hangs on accept() method.
I am run the client by --> new Client("db0",5000); ---> the
client code is socket = new Socket( host, port );
Then i run the server by ---> new Server(5000).
Anybody have any idea why ? Is there any sample code for java
chat in web??
Below is the server code:
private void listen( int port ) throws IOException {
// Create the ServerSocket
ss = new ServerSocket( port );
// Tell the world we're ready to go
System.out.println( "Listening on "+ss );
// Keep accepting connections forever
while (true) {
// Grab the next incoming connection
try{
Socket s = ss.accept(); <---this
// Tell the world we've got it
System.out.println( "Connection from "+s );
// Create a DataOutputStream for writing data to the
// other side
DataOutputStream dout = new DataOutputStream(
s.getOutputStream() );
// Save this stream so we don't need to make it again
outputStreams.put( s, dout );
// Create a new thread for this connection, and then forget
// about it
new ServerThread( this, s );
}
catch(Exception e){
e.printStackTrace();
}
}
}
Technical Details
Message-ID:
<3B1B0312.800770AD@cesmainternational.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!grolier!fr.usenet-edu.net!usenet-edu.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,770f043c19ec820d,start X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-06-03 20:42:44 PST Message-ID: <3B1B0312.800770AD@cesmainternational.com> Date: Mon, 04 Jun 2001 11:40:02 +0800 From: Russell <weetat@cesmainternational.com> X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.13-0.13 i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: Chat applet Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 203.126.155.39 X-Trace: dnews 991626026 203.126.155.39 (3 Jun 2001 20:40:26 -0700) Lines: 58 Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!grolier!fr.usenet-edu.net!usenet-edu.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews