Hi guys,
I was wondering if any of you have any problems opening a Java socket
in Windows 2003. My code works fine in Windows XP, and Windows 9x.
Is there anything special I need to do in order to get Windows to
allow me to open a ****t for me?
Here is a ****tion of my code:
CLIENT SIDE:
im****t java.net.*;
im****t java.io.*;
public class TestSocket{
public static void main(String[] args) throws IOException{
String server = "10.0.0.250";
int ****t = 7;
Socket sock = new Socket(server, ****t);
OutputStream out = sock.getOutputStream();
String message = "Test";
byte[] byteBuffer = message.getBytes();
out.write(byteBuffer);
}
}
SERVER SIDE:
im****t java.net.*;
im****t java.io.*;
public class TCPEchoServer{
private static final int BUFSIZE = 32;
public static void main(String[] args) throws IOException{
if (args.length != 1)
throw new IllegalArgumentException("Parameter(s): <****t>");
int serv****t = Integer.parseInt(args[0]);
ServerSocket servSock = new ServerSocket(serv****t);
int recvMsgSize;
byte[] byteBuffer = new byte[BUFSIZE];
for(;;){
Socket clntSock = servSock.accept();
System.out.println("Handling client at " +
clntSock.getInetAddress().getHostAddress() +
" on ****t " + clntSock.get****t());
InputStream in = clntSock.getInputStream();
OutputStream out = clntSock.getOutputStream();
while((recvMsgSize = in.read(byteBuffer)) != -1)
out.write(byteBuffer, 0, recvMsgSize);
clntSock.close();
}
}
}