Author Topic: Change IP adress  (Read 8347 times)

Offline Forrest

  • Newbie
  • *
  • Posts: 4
    • View Profile
Change IP adress
« on: January 29, 2009, 02:59:06 PM »
Hi Mark,

I wrote simple TCP clients. So I have 4 connections whitch all the time sending reguests to server and reading data. I need change ip adress (server).
Must I close TCP connection, release socket and again get socket and connect (with other IP) to different server? Or is any simplest way to change IP?

Thanks Forrest

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Change IP adress
« Reply #1 on: January 29, 2009, 03:10:32 PM »
Hi Forrest

A TCP connection is unique and has the parameters (IP address of client - port address of client - IP address of server - port address of server).
This means that it is necessary to first close any existing connection, then establish a new connection to the new IP / port combination.

If you are working as a client you don't need to release the socket, just close the connection and reconnect to the new IP address.

Regards

Mark