Hi, i have been making a server for a client I made to connect to. I don't have a static IP, so I need a way for someone on another computer to connect to me without me telling the user what it is every time.
I have tried to just enter another IP in the inet_addr() funtion but then it can't bind.
Please Help...:confused:
SOCKET sServer;
sServer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sServer == INVALID_SOCKET || iError == 1){
MessageBox(NULL, (LPCTSTR)"Invalid Socket!", (LPCTSTR)"Server::Error", MB_OK|MB_ICONERROR);
WSACleanup();
return 0;
}
SOCKADDR_IN sinServer;
memset(&sinServer, 0, sizeof(sinServer));
sinServer.sin_family = AF_INET;
sinServer.sin_addr.s_addr = inet_addr("127.0.0.1"); // Where to start server?
sinServer.sin_port = htons(1000); // Port
if(bind(sServer, (LPSOCKADDR)&sinServer, sizeof(sinServer)) == SOCKET_ERROR){
/* failed at starting server */
MessageBox(NULL, (LPCTSTR)"Could not bind the server!", (LPCTSTR)"Server::Error", MB_OK|MB_ICONERROR);
WSACleanup();
return 0;
}