Results 1 to 5 of 5
  1. #1
    Dufresne is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Question Port Number Changes on Server

    Hi,
    I've two different java codes, one server and one client.

    Server listens on port 6789, and client sends messages on same port 6789.
    Server gets client messages , no problem with that ,but when i print the port that message received from, it's different than 6789, and it changes everytime whenever i run client.
    Example ; when i run client first time and send a message
    server says it came from port 1927 after that i stop client and run again, next message is recevied from port 1928.

    Why port number changes ? Why it isn't the same port number that i listen ?
    :confused:

  2. #2
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    You are probably seeing the client port, not the server port. The client port will be chosen randomly (not really randomly, but indeterminately) for each connection. There is no need for client traffic to come from any particular port.

    -Gary-

  3. #3
    Dufresne is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by gcalvin View Post
    You are probably seeing the client port, not the server port. The client port will be chosen randomly (not really randomly, but indeterminately) for each connection. There is no need for client traffic to come from any particular port.

    -Gary-
    I didnt get it. I send packet with port 6789 from client. Do you say that client doesnt send over port 6789 , it sends over random port ?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Dufresne View Post
    I didnt get it. I send packet with port 6789 from client. Do you say that client doesnt send over port 6789 , it sends over random port ?
    There are two ports involved here, the server port which you specify and the client port which you don't. The client must specify which port it's sending the packet to (the server port).

  5. #5
    Dufresne is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

Similar Threads

  1. Replies: 4
    Last Post: 03-16-2012, 11:40 AM
  2. Replies: 5
    Last Post: 02-17-2010, 06:36 PM
  3. Finding a number in array close to another number
    By SteroidalPsycho in forum New To Java
    Replies: 2
    Last Post: 02-15-2010, 12:37 AM
  4. Printing the Number of Times a Number in a Range Shows up
    By space4rent00 in forum New To Java
    Replies: 1
    Last Post: 02-05-2010, 10:42 PM
  5. Replies: 7
    Last Post: 11-25-2009, 11:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •