Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error recognizing IP and Port from Client using getInetAddress getHostAddress and .getLocalPort  RSS feed

 
Fernando Skackauskas
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have a program that receives via socket a data packet. My program is the Server

I need to give back to the Client that has been received or not.

But when I try to identify the IP and Client port, it returns "0.0.0.0.0" and the port is the same port from my Server.

I am using the following commands:



At this point, the remoteIP = "0.0.0.0" and the same RemotePort = Server (2712).

Where is the mistake? wHY it does not recognize the IP and client port by getInetAddress and getLocalPort command?

Thank you,

Fernando
 
Ron McLeod
Saloon Keeper
Posts: 1430
207
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be working with the socket returned by the accept() rather than the server's listening socket. For example the port of the remote socket would be returned by s.getPort().

Also - this post belongs in the Sockets and Internet Protocols forum, the Ranch Office forum is for issues related to the site itself.
 
Campbell Ritchie
Sheriff
Posts: 53769
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now somebody has suggested which forum this discussion belongs in (thank you), I can move it!
No, somebody has beaten me to it and it has already been moved.
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fernando,

Please choose the forum carefully before posting a question.

I've moved your post to Sockets forum.
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell, I won this round!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!