0

Hello all, i working on a server I have realized that it only is using the loop back address of my ip. It looks like this.

struct sockaddr_in from;

	        int fromLen = sizeof(from);
        SOCKET msgSocket = accept(listenSocket, (struct sockaddr*)&from, &fromLen);
	        if(msgSocket == INVALID_SOCKET){
	            cout<<"Error at accept: "<<WSAGetLastError()<<endl;
	            closesocket(listenSocket);
	            WSACleanup();
	            return 0;

I didn't post all the code because its unnecessary. The loop back address 127.0.0.1 is in from.sin_addr . I do not want to use this i want to use the external address. Is there an external address within the struct sockaddr_in somewhere. The accept function i really want to keep using requires an address from the struct type sockaddr_in, so i hope it has the external address. Thank for any advice.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by BobS0327
0

Is there an external address within the struct sockaddr_in somewhere?

Nope. You have two options:

1. Routers use a web interface and/or telnet for admin purposes. Thus, you may try to read the external IP address from that.

2. Otherwise, you'll have to use an internet resource such as www.whatsmyip.com or www.dyndns.com to do a http query and parse out the external IP address.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.