Hi,
I am currently coding a program that allows you to share files between two computers by way of ip address. Its going to work like this. The client receives the IP address from the server then connects via an open port that the server has allowed to be open. What I dont get is how to get the server side IP. Can anyone help me with this? Thanks in advance.
RIF
I am currently coding a program that allows you to share files between two computers by way of ip address. Its going to work like this. The client receives the IP address from the server then connects via an open port that the server has allowed to be open. What I dont get is how to get the server side IP. Can anyone help me with this? Thanks in advance.
RIF
gethostname(), gethostbyname()
umm arent those used to get the ip of my machine and not the server side? I use them to get my ip but never heard of them being used to get server side ip..
getpeername() then
okay ill try it...
From MSDN description of the "accept" API:
addr
An optional pointer to a buffer that receives the address of the connecting entity, as known to the communications layer. The exact format of the addr parameter is determined by the address family established when the socket was created.
Meaning you just supply a sockaddr structure and it'll give you the address of the computer connecting to you. Of course if you're the client you should already have the address.
addr
An optional pointer to a buffer that receives the address of the connecting entity, as known to the communications layer. The exact format of the addr parameter is determined by the address family established when the socket was created.
Meaning you just supply a sockaddr structure and it'll give you the address of the computer connecting to you. Of course if you're the client you should already have the address.
there would have to be some way for the server to send it's IP to the client, meaning the server would need the clients IP or some place where it can pick up the clients IP.
For example when somone wants to send a file over IRC the persons IRC client opens a port and then sends his IP and PORT number to the person he wants to send the file to
Hope this helps
For example when somone wants to send a file over IRC the persons IRC client opens a port and then sends his IP and PORT number to the person he wants to send the file to
Hope this helps
If both client and server are connected, there is no need to send any of IPs as both can get them with getpeername().
Okay, thanks for all the help guys. Its really helped me out with this. Im still working on it though. Ill fill you guys in with my status when I get done.