C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 03-28-2004, 06:48 PM   #1
C++
 
elitesyntax's Avatar
 
Join Date: Mar 2004
Posts: 12
Socket's

if you have a socket handle how can you know the IP of it in C or C++
__________________
Compiler Gcc

Last edited by elitesyntax; 03-28-2004 at 08:04 PM.
elitesyntax is offline   Reply With Quote
Old 03-29-2004, 02:36 AM   #2
sockets mad
 
Join Date: Mar 2002
Posts: 126
sockaddr structure will hold all that information. Read up on it.

When you call the accept() function the second parameter (i think) is a pointer to a sockaddr structure to fill with the information regarding the connecting device.

-Dan
codec is offline   Reply With Quote
Old 03-29-2004, 10:35 AM   #3
'AlHamdulillah
 
Join Date: Feb 2003
Posts: 790
Quote:
Originally Posted by codec
sockaddr structure will hold all that information. Read up on it.

When you call the accept() function the second parameter (i think) is a pointer to a sockaddr structure to fill with the information regarding the connecting device.

-Dan
I think that he is referring to,"How can I, with just a socket handle, get the ip address"....


to be honest, I dont know, after looking through some unix man pages, I cannot find any function that will return the address of the other side of a socket.
EvBladeRunnervE is offline   Reply With Quote
Old 03-29-2004, 11:58 AM   #4
Registered User
 
Join Date: Nov 2001
Posts: 1,348
Under Win32 platform, definitely. I am not familiar on the UNIX platform.

Kuphryn
kuphryn is offline   Reply With Quote
Old 03-29-2004, 01:00 PM   #5
Yes, my avatar is stolen
 
anonytmouse's Avatar
 
Join Date: Dec 2002
Posts: 2,544
getpeername() - Available on all platforms.
anonytmouse is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to poll sockets? 39ster Networking/Device Communication 3 07-22-2008 01:43 PM
Cross platform sockets zacs7 Networking/Device Communication 5 06-27-2007 05:16 AM
multiple UDP sockets with select() nkhambal Networking/Device Communication 2 01-17-2006 07:36 PM
Raw Sockets and SP2... Devil Panther Networking/Device Communication 11 08-12-2005 04:52 AM
Starting window sockets _Cl0wn_ Windows Programming 2 01-20-2003 11:49 AM


All times are GMT -6. The time now is 05:50 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22