Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Codewarrior Java > Java Socket Pro...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 28 of 81
Post > Topic >>

Java Socket Programming in Windows Server 2003

by jcroasdaleii@[EMAIL PROTECTED] (ViPeR) Dec 14, 2003 at 05:59 PM

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();
		}
	}
}
 




 1 Posts in Topic:
Java Socket Programming in Windows Server 2003
jcroasdaleii@[EMAIL PROTE  2003-12-14 17:59:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 6 15:16:14 CDT 2008.