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

    Default TCP Socket reconnection using same local part

    I've a problem with TCP Sockets.

    When my client lost the network connection with the server, it tries to create a new Socket and connect again. (It's trying to create a connection every five seconds)

    When the network connection is ok, the application creates a new Socket, it connects with the server, and closes the first socket, but when the client send messages to it, the server is not sending the answers to the new socket.

    I saw that server sends the answers to the port of the closed socket and not to the connected socket port.

    I can't modify the server because I have not the source code. I need solve the problem modifying the client.

    It's possible to connect with server always with the same local port? How? I tried to set setReuseAddress to true but the local port of the socket is always diffrenet.

    If isn't possible to do this. How can I force to server to send messages/answers to new local port?
    Last edited by Blaine; 05-06-2010 at 04:22 PM.

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

    Default

    Take another look at the Socket API. There is a constructor that takes a local address and local port as parameters.

    -Gary-

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  4. #4
    chethukt is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default

    Hi,
    I am trying to send a file over a network using sockets. I have connection as mentioned below...

    NODE A - NODE C - NODE B

    So to send a file to NODE B, I have to find the port number and host name of NODE B, and after finding the port and host name, I can not read the file from the old port and host name and the file written to the destination is of empty contents.

    Can I use any buffer to save the file contents and to write it to the file at the destination..


    Please help me.....

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    If you want to send a file to another location you must know the credentials in advance. Without knowing that how can you do anything on it, basically how can you make a connection?

Similar Threads

  1. Local Finals
    By Drun in forum New To Java
    Replies: 6
    Last Post: 11-20-2009, 06:50 AM
  2. Transient & Local
    By Supamagier in forum Advanced Java
    Replies: 5
    Last Post: 04-28-2009, 02:35 AM
  3. Local IP
    By andrewms in forum Networking
    Replies: 5
    Last Post: 04-25-2009, 01:54 AM
  4. append response to the request from Socket and write to another socket
    By vaibhav_singh_vs@yahoo.co in forum Networking
    Replies: 3
    Last Post: 04-17-2009, 07:02 PM
  5. Updating Local Content
    By ibanez270dx in forum Java Applets
    Replies: 1
    Last Post: 11-02-2007, 01:55 AM

Posting Permissions

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