Hello everyone!
I made a simple server program and put it on my desktop. I can connect to it via the network. (Local Ip: 192.168.1.32), but I can't connect to it by its public ip 74.82.2**.***. Yes I portforwarded the desktop. I run a minecraft server on the same pc and it works perfectly fine. I starred most of my IP so no one gets any ideas. The desktop also has a static IP.
import java.net.*; import java.io.*; public class srv_main { public static void main(String[] args) throws IOException { ServerSocket ssock = null; try { ssock = new ServerSocket(4456); } catch (IOException e) { e.printStackTrace(); System.err.println("[ERROR]: Could not listen on port 4456. Other server running?"); System.exit(-1); } System.out.println("[SERVER]: Server started on port: 4456"); Socket sock = null; try { sock = ssock.accept(); } catch (IOException e1) { System.err.println("[ERROR]: Accept failed."); System.exit(-1); } System.out.println("[SERVER]: Client connected"); PrintWriter out = new PrintWriter(sock.getOutputStream(), true); BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream())); String input; while((input = in.readLine()) != null) { System.out.println("[SERVER]: From Client: " + input); if ("bye".equals(input)) { out.println("Bye bye <3"); break; } else { out.println(input+": From server <3"); } } System.out.println("[SERVER]: Shutting Down"); out.close(); in.close(); sock.close(); ssock.close(); System.out.println("[SERVER]: Shutdown Complete"); } }