Prev: Bitmap dialogs
Next: CComQIPtr and XML question
From: bernd on 25 May 2010 09:02 Hi, is it possible to get some more information (in the OnReceive-method) about a received ethernet packet (for example; the ip-addr and / or mac addr from the sender)? I`m using casyncsocket; a udp-listener (at a specific port) best regards Bernd
From: Stephen Myers on 25 May 2010 09:36 bernd wrote: > Hi, > > is it possible to get some more information (in the OnReceive-method) > about a received ethernet packet (for example; the ip-addr and / or > mac addr from the sender)? > > I`m using casyncsocket; a udp-listener (at a specific port) > > > best regards > Bernd Use ReceiveFrom(). The 3rd and 4th parameters identify the sender. HTH Steve
From: Hector Santos on 25 May 2010 10:27 bernd wrote: > Hi, > > is it possible to get some more information (in the OnReceive-method) > about a received ethernet packet (for example; the ip-addr and / or > mac addr from the sender)? > > I`m using casyncsocket; a udp-listener (at a specific port) 1) The IP-ADDR is easy from the socket handle: CAsyncSocket::GetPeerName() It would be redundant to do this in the OnReceive() since it will never change. Do it once with the OnConnect(). 2) But for the mac address of the client, it depends. The MAC ADDR is part of your NETWORK of computers. Not the OTHER GUYS network of computers. You must be at least on the same subnet. For just any client that is not part of your LAN, just sending your a TCP/UPD packet, you will not see it. Only for a client that is connecting you to establish a PPP connection does the MAC can passed during the link negotiation phase. In other words, you are acting as ISP or host that has a PPP server and your users connecting to you to get an IP address. They are now part of your "LAN" Nonetheless, if the SENDER is part of your network, you can use the SendARP() which is part of the IP HELPER LIBRARY. See SendARP on MSDN. -- HLS
From: Stephen Myers on 25 May 2010 11:32 See my comments below: Hector Santos wrote: > bernd wrote: > >> Hi, >> >> is it possible to get some more information (in the OnReceive-method) >> about a received ethernet packet (for example; the ip-addr and / or >> mac addr from the sender)? >> >> I`m using casyncsocket; a udp-listener (at a specific port) > > 1) The IP-ADDR is easy from the socket handle: > > CAsyncSocket::GetPeerName() > > It would be redundant to do this in the OnReceive() since it will > never change. Do it once with the OnConnect(). There is no OnConnect with UDP. You can receive from multiple clients on the same socket. > > 2) But for the mac address of the client, it depends. > > The MAC ADDR is part of your NETWORK of computers. Not the OTHER GUYS > network of computers. You must be at least on the same subnet. > > For just any client that is not part of your LAN, just sending your a > TCP/UPD packet, you will not see it. > > Only for a client that is connecting you to establish a PPP connection > does the MAC can passed during the link negotiation phase. > > In other words, you are acting as ISP or host that has a PPP server and > your users connecting to you to get an IP address. They are now part of > your "LAN" > > Nonetheless, if the SENDER is part of your network, you can use the > SendARP() which is part of the IP HELPER LIBRARY. See SendARP on MSDN. > Steve
From: Hector Santos on 25 May 2010 11:51
See my single line comment in embedded and buried in an over quoted response below: Stephen Myers > wrote: > See my comments below: > > Hector Santos wrote: >> bernd wrote: >> >>> Hi, >>> >>> is it possible to get some more information (in the OnReceive-method) >>> about a received ethernet packet (for example; the ip-addr and / or >>> mac addr from the sender)? >>> >>> I`m using casyncsocket; a udp-listener (at a specific port) >> >> 1) The IP-ADDR is easy from the socket handle: >> >> CAsyncSocket::GetPeerName() >> >> It would be redundant to do this in the OnReceive() since it will >> never change. Do it once with the OnConnect(). > > There is no OnConnect with UDP. You can receive from multiple clients > on the same socket. I missed he mentioned udp. Then using ReceiveFrom() is the right way, > >> >> 2) But for the mac address of the client, it depends. >> >> The MAC ADDR is part of your NETWORK of computers. Not the OTHER GUYS >> network of computers. You must be at least on the same subnet. >> >> For just any client that is not part of your LAN, just sending your a >> TCP/UPD packet, you will not see it. >> >> Only for a client that is connecting you to establish a PPP connection >> does the MAC can passed during the link negotiation phase. >> >> In other words, you are acting as ISP or host that has a PPP server >> and your users connecting to you to get an IP address. They are now >> part of your "LAN" >> >> Nonetheless, if the SENDER is part of your network, you can use the >> SendARP() which is part of the IP HELPER LIBRARY. See SendARP on MSDN. >> > > Steve -- HLS |