Hello,
I'm trying to establish a Client-to-Client connection over Java. I'd like to avoid having a seperate Server application (if possible). You'll have to forgive me, I'm fairly new to Java.
If anyone could offer any advice/resources, I'd really appreciate it.
What I'm hoping to happen is someone will create an instance of my class (NetworkConnection nc = new NetworkConnection(ipaddr, portnum)), which would open the connection to another computer.
If you could offer me any help at all, whatsoever, I'd be very appreciative.
-------------------------
Just call me Captain Awesome.
I'm trying to establish a Client-to-Client connection over Java. I'd like to avoid having a seperate Server application (if possible). You'll have to forgive me, I'm fairly new to Java.
If anyone could offer any advice/resources, I'd really appreciate it.
Code:
public static void main(String args[]) {
NetworkConnection NCClass = new NetworkConnection();
NCClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String ipadd = "127.0.0.1";
int portnum = 6000;
try {
Socket sock = new Socket(ipadd, portnum);
BufferedReader input = new BufferedReader(new InputStreamReader(sock.getInputStream()));
PrintWriter = output = new PrintWriter(sock.getOutputStream());
System.out.println("Connection established to " + sock.getInetAddress());
}
catch (IOException e) {
System.out.println("Connection Lost " + e);
}
}
What I'm hoping to happen is someone will create an instance of my class (NetworkConnection nc = new NetworkConnection(ipaddr, portnum)), which would open the connection to another computer.
If you could offer me any help at all, whatsoever, I'd be very appreciative.
-------------------------
Just call me Captain Awesome.