Knowing the connected client
-
client=accept(serv,(struct sockaddr*)&frm,&frmlen);
This line gets the client that connects from a remote machine. Now how do we know from which machine did that connect? How do we get the machine name or IP address. Is there any function that gets in the SOCKET as input and returns IP address or Name?
---------------------------- 286? WOWW!:-O
-
client=accept(serv,(struct sockaddr*)&frm,&frmlen);
This line gets the client that connects from a remote machine. Now how do we know from which machine did that connect? How do we get the machine name or IP address. Is there any function that gets in the SOCKET as input and returns IP address or Name?
---------------------------- 286? WOWW!:-O
_8086 wrote:
Now how do we know from which machine did that connect?
client = accept(serv, (struct sockaddr *) &frm, &frmlen);
char *clienthost = inet_ntoa(frm.sin_addr);
int port = ntohs(frm.sin_port);
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
_8086 wrote:
Now how do we know from which machine did that connect?
client = accept(serv, (struct sockaddr *) &frm, &frmlen);
char *clienthost = inet_ntoa(frm.sin_addr);
int port = ntohs(frm.sin_port);
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb