I am writing some basic client server code, and I need to get the ip address of the client so I can log it. I use the following...
int sockfd, newsockfd, clilen;
struct sockaddr_in cli_addr;
set up listen on sockfd
clilen = sizeof(cli_addr);
newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
process communications on newsockfd.
I have tried several iocntl and fcntl calls, but all I get is garbage. I tried getpeername, and getsocketname, but all I get is unitelligable garbage.