Thread View: aus.computers.java
1 messages
1 total messages
Started by Graham Brownridge
Sun, 09 May 1999 00:00
Help!
Author: Graham Brownridge
Date: Sun, 09 May 1999 00:00
Date: Sun, 09 May 1999 00:00
44 lines
1896 bytes
1896 bytes
I am trying to create an echo server, here is my (buggy) source code:
import java.io.*;
import java.util.*;
import java.net.*;
public class n {
public static void main(String args[]) throws IOException {
ServerSocket ssok = new ServerSocket(7);
Thread theSvr;
while (true) {
System.out.println("Server: Listening on port 7");
Socket sok = ssok.accept();
System.out.println("Server: Connection Request recieved");
Svr nooSvr = new Svr(sok);
theSvr = new Thread(nooSvr);
theSvr.start();
}
}
}
class Svr implements Runnable {
Socket sok;
public Svr(sok) throws IOException {
}
public void run() {
Socket sock = sok;
DataInputStream inbound = new DataInputStream(sock.getInputStream());
DataOutputStream outbound = new DataOutputStream(sock.getOutputStream());
String inLine = inbound.readline();
}
}
On compiling it says a) Identifier expected
public Svr(sok) throws IOException
{
^
b)Wrong number of arguments in
constructor.
Svr nooSvr = new Svr(sok);
^
Can anyone tell me how to fix it???
James
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads