On Saturday 29 April 2006 07:09, Roshan wrote:
> Tried, this today again, and now it does, create a
> server on port 4000, but still takes around 7-8
> minutes.
you must've screwed up your system...
> I thought, Java was preferred for networking
> programming and assumed, this would be true atleast
> for the years to come by. Is it true?
Dunno. I hate Java. I wouldn't use it if my life depended on it :/
> Ah, for the moment, I don't think, I would be doing it
> in C, atleast till I am sure, I can do it.
hehehe :)
> I do google, a lot more, but solutions seem to be
> passive, which does seem to help all the time. At
> these times, I post to the list!
right ;)
The code below works perfectly for me. I have shamelessly copied it from
some website whose address I dont remember. I modified it a bit for our
needs ofcourse. I have built it using gcj and java on my FC2 system and
it works perfectly. It has no issues binding to port 4000.
import java.io.*;
import java.net.*;
public class echoServer {
public static void main(String args[]) {
ServerSocket echoServer = null;
String line;
DataInputStream is;
PrintStream os;
Socket clientSocket = null;
try {
echoServer = new ServerSocket(4000);
}
catch (IOException e) {
System.out.println(e);
}
try {
clientSocket = echoServer.accept();
is = new DataInputStream(clientSocket.getInputStream());
os = new PrintStream(clientSocket.getOutputStream());
while (true) {
line = is.readLine();
System.out.println("Client: " + line);
os.println("Server: " + line);
}
}
catch (IOException e) {
System.out.println(e);
}
}
}
--
Dinesh A. Joshi
--
http://mm.glug-bom.org/mailman/listinfo/linuxers