I was testing out a networking script of mine, and it worked fine locally. It is basically a replica of a very bare bones multiplayer game network, where multiple clients connect to a master server, each client can say anything that it wants, and the server redirects that message to all the other clients it has. This is multithreaded and it runs prefectly locally, I can make any number of connections that I want. My problem begins when I tell my friend to connect. I know everything is fine on the port because he can ping my IP address just fine and there is no loss of packets. I try and use port 3000, and when my friend tries and connect, he just cannot. Does anyone know why this happens?
WargRider
10
Junior Poster
Recommended Answers
Jump to PostAre you by any chance spawing the server process by passing in the host as "localhost" or "127.0.0.1"? If yes, then AFAIK you need to replace the same with the IP address assigned by your network in case your friend is in the same network or the IP address …
Jump to PostThe problem isn't with port but with the host. If you don't pass in a host, it defaults to 0.0.0.0 or 127.0.0.1 (not very sure here); which again gives rise to the scenario I explained in my previous post. Refer the three arg constructor of ServerSocket …
Jump to Post"Crashes the server" isn't a very good description. Post the relevant code along with complete stack trace. Also, you don't pass in your WAN IP but *your* IP (assigned by your ISP or your network).
Jump to PostUse
getByAddress
instead ofgetByName
since you are passing an IP address and not a host name.byte[] ipBytes = new byte[] { 192, 192, 192, 192 }; InetAddress ip = InetAddress.getByAddress(ipBytes); ServerSocket server = new ServerSocket(9090, -1, ip); while(true) { Socket client = server.accept(); …
Jump to PostIt works at my place so it obviously has got something to do with the IP address you are using. Also, try a higher port value, like 8080, to make sure the problem isn't with lower ports being blocked. Also, like I said, post the *entire* stack trace unmodified and …
All 21 Replies
WargRider
10
Junior Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
WargRider
10
Junior Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
WargRider
10
Junior Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
WargRider
10
Junior Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
WargRider
10
Junior Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
WargRider
10
Junior Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
WargRider
10
Junior Poster
WargRider
10
Junior Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
WargRider
10
Junior Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
WargRider
10
Junior Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
bulger2503
0
Newbie Poster
WargRider
10
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.