[Sorry for cross posting]. I have a very basic server written in C. It creates a socket, binds it to a port and listens for client's requests. I am trying to find the IP address of the client when the client attempts to make a connection. Does anyone know how to do that? (I was hoping to have client structure filled in when client establishes connection, but that doesn't seem to be the case.)
Here is the trimmed code (can send complete code if you so desire). Tanks, Nishi #includes int main() { struct sockaddr_in server; struct sockaddr client; struct hostnet *hp; sock1 = socket(AF_INET, SOCK_STREAM, 0); memset(&server, 0, sizeof(server)); server.sin_family = "127.0.0.1"; server.sin_addr.s_addr = htonl(INADDR_ANY); server.sin_port = htons(atoi(argv[1])); rc = bind(sock1, (struct sockaddr *)&server, sizeof(server)); rc = listen(sock1, 32); rc = listen(sock2, 32); while (1) { printf("Waiting on select()...\n"); rc = select(32, &sock, NULL, NULL, &timeout); rc = accept(msgSock, &client, &addrlen); fprintf (stdout, "client.sa_data=%s \n", client.sa_data); fprintf (stdout, "Client's IP address: %s \n", "???"); fprintf (stdout, "Client's port no: %s \n", "???"); } } /* end of main() */ _______________________________________________ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/