<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2" -->
<rss version="2.0">
    <channel>
        <title>Lowyat.NET: Latest topics by umar602</title>
        <description></description>
        <link>http://forum.lowyat.net/</link>
        <lastBuildDate>Sun, 29 Nov 2026 21:46:00 +0800</lastBuildDate>
        <generator>FeedCreator 1.7.2</generator>
        <item>
            <title>plzzz help ... i got problem with ths coode</title>
            <link>http://forum.lowyat.net/topic/822908</link>
            <description>hii.. i need to knw how to chnge ths program to become multi chatting instat of one single line chatting.. so, tht i dont have to wit for the other users to reply..thnx in advance...here is the code..&lt;br /&gt;the server:&lt;br /&gt;import java.net.*;&lt;br /&gt;import java.io.*;&lt;br /&gt;import java.util.Scanner;&lt;br /&gt;public class Server {&lt;br /&gt;public static void main(String[] ar) {&lt;br /&gt;Scanner scan = new Scanner(System.in);&lt;br /&gt;System.out.print(&amp;quot;Port: &amp;quot;);&lt;br /&gt;int port = scan.nextInt(); // just a random port. make sure you enter something between 1025 and 65535.&lt;br /&gt;&lt;br /&gt;try {&lt;br /&gt;BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));&lt;br /&gt;ServerSocket ss = new ServerSocket(port); // create a server socket and bind it to the above port number.&lt;br /&gt;System.out.println(&amp;quot;Waiting for a client...&amp;quot;);&lt;br /&gt;Socket socket = ss.accept(); // make the server listen for a connection, and let you know when it gets one.&lt;br /&gt;System.out.println(&amp;quot;Got a client &lt;!--emo&amp;:)--&gt;&lt;img src='http://static.lowyat.net/style_emoticons/default/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /&gt;&lt;!--endemo--&gt; ... Finally, someone saw me through all the cover&amp;#33;&amp;quot;);&lt;br /&gt;System.out.println();&lt;br /&gt;// Get the input and output streams of the socket, so that you can receive and send data to the client.&lt;br /&gt;InputStream sin = socket.getInputStream();&lt;br /&gt;OutputStream sout = socket.getOutputStream();&lt;br /&gt;// Just converting them to different streams, so that string handling becomes easier.&lt;br /&gt;DataInputStream in = new DataInputStream(sin);&lt;br /&gt;DataOutputStream out = new DataOutputStream(sout);&lt;br /&gt;String line = null;&lt;br /&gt;while(true) {&lt;br /&gt;line = in.readUTF(); // wait for the client to send a line of text.&lt;br /&gt;System.out.println(&amp;quot;Client says: &amp;quot; + line);&lt;br /&gt;//System.out.println(&amp;quot;I&amp;#39;m sending it back...&amp;quot;);&lt;br /&gt;&lt;br /&gt;System.out.print(&amp;quot;Server says: &amp;quot;);&lt;br /&gt;line = keyboard.readLine(); // wait for the user to type in something and press enter.&lt;br /&gt;out.writeUTF(line); // send the same line back to the client.&lt;br /&gt;out.flush(); // flush the stream to ensure that the data reaches the other end.&lt;br /&gt;//System.out.println(&amp;quot;Waiting for the next line...&amp;quot;);&lt;br /&gt;//System.out.println();&lt;br /&gt;}&lt;br /&gt;} catch(Exception x) {x.printStackTrace();}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;the client:&lt;br /&gt;import java.net.*;&lt;br /&gt;import java.io.*;&lt;br /&gt;import java.util.Scanner;&lt;br /&gt;public class Client {&lt;br /&gt;public static void main(String[] ar) {&lt;br /&gt;Scanner scan = new Scanner(System.in);&lt;br /&gt;System.out.print(&amp;quot;Port: &amp;quot;);&lt;br /&gt;int serverPort = scan.nextInt(); // make sure you give the port number on which the server is listening.&lt;br /&gt;System.out.print(&amp;quot;IP Address: &amp;quot;);&lt;br /&gt;String address = scan.next(); // this is the IP address of the server program&amp;#39;s computer. // the address given here means &amp;quot;the same computer as the client&amp;quot;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;try {&lt;br /&gt;InetAddress ipAddress = InetAddress.getByName(address); // create an object that represents the above IP address.&lt;br /&gt;System.out.println(&amp;quot;Any of you heard of a socket with IP address &amp;quot; + address + &amp;quot; and port &amp;quot; + serverPort + &amp;quot;?&amp;quot;);&lt;br /&gt;Socket socket = new Socket(ipAddress, serverPort); // create a socket with the server&amp;#39;s IP address and server&amp;#39;s port.&lt;br /&gt;System.out.println(&amp;quot;Yes&amp;#33; I just got hold of the program.&amp;quot;);&lt;br /&gt;// Get the input and output streams of the socket, so that you can receive and send data to the client.&lt;br /&gt;InputStream sin = socket.getInputStream();&lt;br /&gt;OutputStream sout = socket.getOutputStream();&lt;br /&gt;// Just converting them to different streams, so that string handling becomes easier.&lt;br /&gt;DataInputStream in = new DataInputStream(sin);&lt;br /&gt;DataOutputStream out = new DataOutputStream(sout);&lt;br /&gt;// Create a stream to read from the keyboard.&lt;br /&gt;BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));&lt;br /&gt;String line = null;&lt;br /&gt;System.out.println(&amp;quot;Type in something and press enter. Will send it to the server and tell ya what it thinks.&amp;quot;);&lt;br /&gt;System.out.println();&lt;br /&gt;&lt;br /&gt;while(true) {&lt;br /&gt;System.out.print(&amp;quot;Client says: &amp;quot;);&lt;br /&gt;line = keyboard.readLine(); // wait for the user to type in something and press enter.&lt;br /&gt;//System.out.println(&amp;quot;Sending this line to the server...&amp;quot;);&lt;br /&gt;out.writeUTF(line); // send the above line to the server.&lt;br /&gt;out.flush(); // flush the stream to ensure that the data reaches the other end.&lt;br /&gt;&lt;br /&gt;line = in.readUTF(); // wait for the server to send a line of text.&lt;br /&gt;System.out.println(&amp;quot;Server says: &amp;quot; + line);&lt;br /&gt;//System.out.println(&amp;quot;Looks like the server is pleased with us. Go ahead and enter more lines.&amp;quot;);&lt;br /&gt;//System.out.println();&lt;br /&gt;}&lt;br /&gt;} catch(Exception x) {x.printStackTrace();}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;thnx aloot..plz if it pasible reply it asap..thnx again...</description>
            <author>umar602</author>
            <category>Codemasters</category>
            <pubDate>Tue, 21 Oct 2008 08:35:33 +0800</pubDate>
        </item>
    </channel>
</rss>
