Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help! - Socket read failed (Windows 95)

0 views
Skip to first unread message

Jo...@file.demon.co.uk

unread,
Jun 30, 1997, 3:00:00 AM6/30/97
to

I've got a problem, I have written 2 problems - 1 client, 1 server using sockets and serversockets I have got the
connection established, BUT I cannot send any information at all between either the client or server or vice versa.
I always get a socket read failed: as BELOW

C:\Dissertation\JDK\bin>java client4
connecting
connected
java.net.SocketException: Socket read failed
at java.net.SocketInputStream.read(SocketInputStream.java:92)
at java.net.SocketInputStream.read(SocketInputStream.java:108)
at java.io.DataInputStream.readLine(DataInputStream.java:253)
at client4.main(client4.java:32)

This is the server DOS information given.

C:\Dissertation\JDK\bin>java server4
opening port
port OK
Verifying server information as:ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=4444]
Accepting connections
Accept made

So what should I do!!!! Could the problem be that these programs are running on 1 PC with Win95. So only the localport
is set not the other port. Here is my code below:
CLIENT CODE:

import java.net.*;
import java.io.*;

class client4{

public static void main(String args[]){

Socket s = null;
try {
System.out.println("connecting");
s = new Socket("194.222.213.205",4444);
System.out.println("connected");

} catch (UnknownHostException e) {
System.out.println("check spelling of hostname");
} catch (ConnectException e) {
System.out.println("connection refused - is server down? Try another port.");
} catch (NoRouteToHostException e) {
System.out.println("The connect attempt timed out. Try connecting through a proxy");
} catch (IOException e) {
System.out.println("another error occurred");
}

try{
DataInputStream In = new DataInputStream(s.getInputStream());
PrintStream Out = new PrintStream(s.getOutputStream());

String inputline;

while ((inputline = In.readLine()) !=null){
System.out.println(inputline);
}
}
catch (IOException e){e.printStackTrace();}
}
}

SERVER CODE:

import java.net.*;
import java.io.*;

class server4{

public static void main(String args[]){

ServerSocket ss = null;
try {
int port = 4444;
int backlog = 1;
InetAddress IP = null;
System.out.println("opening port");
ss = new ServerSocket(port, backlog, IP);
System.out.println("port OK");
} catch (UnknownHostException e) {
System.out.println("unknown host");
} catch (IOException e) {
System.out.println("IO exception");
}

String PrintInfo = ss.toString();
System.out.println("Verifying server information as:" + PrintInfo);

Socket clientSocket = null;
try{
System.out.println("Accepting connections");
clientSocket = ss.accept();
System.out.println("Accept made");
} catch (IOException e) {
System.out.println("Accept failed!!!!");
}

try{
DataInputStream In = new DataInputStream(
new BufferedInputStream(clientSocket.getInputStream()));

PrintStream Out = new PrintStream(
new BufferedOutputStream(clientSocket.getOutputStream()));

String Outputline;

Outputline = "Hello server!";

Out.println(Outputline);
}
catch (IOException e){e.printStackTrace();}
}
}

Please help me!
Panicking UK student.....From Manchester

John

0 new messages