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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.