G
Greyham
I'm trying to get a Java client to recieve data from a C++ server but
the java client crashes as soon as I try the readLine() function of my
bufferedreader. My C++ server is the one from MSDN at:
http://msdn.microsoft.com/library/d...n-us/winsock/winsock/complete_server_code.asp
And here's my Java code:
import java.net.*;
import java.io.*;
public class tcpClientString {
public static void main(String[] args) {
int port = 1500;
String server = "localhost";
Socket socket = null;
BufferedReader input;
// connect to server
/*.....code.....*/
try {
System.out.println("one");
input = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
System.out.println("two");
String message = input.readLine();
System.out.println("three");
System.out.println(message);
}
catch (IOException e) {
System.out.println(e);
}
// closing connection
/*....code....*/
}
}//////////////END OF CODE/////////////////////
So my java output tells me I've connected to the server and then I get
the messages "one" and "two" but then "Java.net.SocketException:
Connection Reset" My C++ code seems to work fine... it tells me I've
sent 22 bytes (message should be "Server: Sending Data.\n"). Thanks
for the help!
the java client crashes as soon as I try the readLine() function of my
bufferedreader. My C++ server is the one from MSDN at:
http://msdn.microsoft.com/library/d...n-us/winsock/winsock/complete_server_code.asp
And here's my Java code:
import java.net.*;
import java.io.*;
public class tcpClientString {
public static void main(String[] args) {
int port = 1500;
String server = "localhost";
Socket socket = null;
BufferedReader input;
// connect to server
/*.....code.....*/
try {
System.out.println("one");
input = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
System.out.println("two");
String message = input.readLine();
System.out.println("three");
System.out.println(message);
}
catch (IOException e) {
System.out.println(e);
}
// closing connection
/*....code....*/
}
}//////////////END OF CODE/////////////////////
So my java output tells me I've connected to the server and then I get
the messages "one" and "two" but then "Java.net.SocketException:
Connection Reset" My C++ code seems to work fine... it tells me I've
sent 22 bytes (message should be "Server: Sending Data.\n"). Thanks
for the help!