Connect Back

have got a c server code with download function and cmd,but problem with the server is connecting back,i tried to post the code but claimed is huge exceeded length prescribed.

I do away with INADDR_ANY; and introduced inet_addr(pIP); to have only my remote Host listened to,


The server executes well if your computer is Not Connected and you used :- struct hostent *he = gethostbyname("localhost");

but fails to executes and crashes if your computer is Disconnected and you used :- struct hostent *he = gethostbyname("remotehost.org");

Maybe because inet_addr(pIP); fails to initiate an ip from "remotehost.org" it needs connections,




So i connect with my noip software running and Client software running and requsting for a Re-connection ,
it fails to connect ,but remember while i launched the server when the computer was connected it executed successfully with all commands i used from client worked well,but i reasoned and decided to disconnect my Pc from connection and connect back since there shall be a new ip, with my no-ip running it showed me my new ip address mapped from hostname,so i input my new ip address to connect to server,the server has the hostname which keeps mapping my ip,
so on connecting it stays longer and prints cant connect,so i kill the server from the process manager and
execute the server again,so i connect with my new ip address i used before i killed the server.So on connecting
it connects well with console panel displaying ready to receive commands.

Why Must it be executed every time physically and to connect it connects well,the server has an auto run which make it
automatic but it only need user access you kill and start it again then you connect , there must be a
code which automates it completely,and that what i want.

so am appealing for some expert in C language to help improve the code basically on reconnecting back after failure,disruption e.t.c,

something like the server can wait for 30 minutes and start to accept a connection after it failed at first.

Some things to try or consider in no particular order:

- Are you rebinding the socket after the disconnect?

- In the command shell on the system running the server, enter
netstat -b
this will list all of the programs on your system with open ports and the state that the ports are in. Look for your server process and see if it is in the 'listening' state. A GUI alternative for this test is "tcpview" from the SysInternals suite.

- From the client try to connect to the server with telnet on the port you opened. What happens?
This part I understand.
I do away with INADDR_ANY; and introduced inet_addr(pIP); to have only my remote Host listened to,


This part I don't understand. Can explain further what you mean, with perhaps a code sample if words won't suffice?
The server executes well if your computer is Not Connected and you used :- struct hostent *he = gethostbyname("localhost");

but fails to executes and crashes if your computer is Disconnected and you used :- struct hostent *he = gethostbyname("remotehost.org");

Maybe because inet_addr(pIP); fails to initiate an ip from "remotehost.org" it needs connections,

Registered users can post here. Sign in or register to post.