Article View: aus.computers.java
Article #1237Help!
From: 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
Technical Details
Message-ID:
<7h4g5a$20g2$1@quince.news.easynet.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d6db,b30a1476f0302e55,start X-Google-Attributes: gid10d6db,public From: "Graham Brownridge" <grahamb67@easynet.co.uk> Subject: Help! Date: 1999/05/09 Message-ID: <7h4g5a$20g2$1@quince.news.easynet.net> X-Deja-AN: 475889326 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 X-Complaints-To: abuse@easynet.net X-Trace: quince.news.easynet.net 926270442 66050 212.212.69.222 (9 May 1999 17:20:42 GMT) Organization: [posted via Easynet Ltd] NNTP-Posting-Date: 9 May 1999 17:20:42 GMT Newsgroups: aus.computers.java