Tuesday, 15 February 2011

c - Get IP address from socket descriptor? -



c - Get IP address from socket descriptor? -

i've opened tcp socket server (i've omitted few stuff, taken here

sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol))

is possible ip address of server sockfd? if not should look?

edit: want know address of server (this before client connects).

if want know who's @ other end of socket can utilize getpeername in linux. getsockname tell are. decide address want server sit down on though, @ bind time.

you may find question useful: bind socket network interface

and book "unix network programming, vol 1", w. richard stevens.

c sockets network-programming ip

No comments:

Post a Comment