[twsocket] UDP Address
Hello! I would like to know if its possible to get the address that a UDP packet comes from. I am making an application that will send multiple packets to different hosts using SendTo and I will be receiving replies from them. I have no power to change the protocol, so I need to know if its possible to find out the address each packet arrived from. Currently, I use bytesread := sock.Receive(@data, SizeOf(data)); to receive the data. where sock is a TWSocket object. sock.Addr will not work here.. :( Thanks for taking your time, - Martin E. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] UDP Address
Have you checked PeerAddr? - Original Message - From: Xealot [EMAIL PROTECTED] To: twsocket@elists.org Sent: Friday, October 17, 2008 04:47 Subject: [twsocket] UDP Address Hello! I would like to know if its possible to get the address that a UDP packet comes from. I am making an application that will send multiple packets to different hosts using SendTo and I will be receiving replies from them. I have no power to change the protocol, so I need to know if its possible to find out the address each packet arrived from. Currently, I use bytesread := sock.Receive(@data, SizeOf(data)); to receive the data. where sock is a TWSocket object. sock.Addr will not work here.. :( Thanks for taking your time, - Martin E. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] UDP Address
Thank you for replying, PeerAddr raises a SocketException 'Error 10057 in function GetPeerName Socket is not connected' Im assuming this is because I didnt actually run sock.Connect with the address I received that packet from? Im only running sock.connect once to avoid changing client port On Fri, Oct 17, 2008 at 4:54 AM, brian [EMAIL PROTECTED] wrote: Have you checked PeerAddr? - Original Message - From: Xealot [EMAIL PROTECTED] To: twsocket@elists.org Sent: Friday, October 17, 2008 04:47 Subject: [twsocket] UDP Address Hello! I would like to know if its possible to get the address that a UDP packet comes from. I am making an application that will send multiple packets to different hosts using SendTo and I will be receiving replies from them. I have no power to change the protocol, so I need to know if its possible to find out the address each packet arrived from. Currently, I use bytesread := sock.Receive(@data, SizeOf(data)); to receive the data. where sock is a TWSocket object. sock.Addr will not work here.. :( Thanks for taking your time, - Martin E. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] UDP Address
Maybe GetPeerAddr? - Original Message - From: Xealot [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Friday, October 17, 2008 05:01 Subject: Re: [twsocket] UDP Address Thank you for replying, PeerAddr raises a SocketException 'Error 10057 in function GetPeerName Socket is not connected' Im assuming this is because I didnt actually run sock.Connect with the address I received that packet from? Im only running sock.connect once to avoid changing client port On Fri, Oct 17, 2008 at 4:54 AM, brian [EMAIL PROTECTED] wrote: Have you checked PeerAddr? - Original Message - From: Xealot [EMAIL PROTECTED] To: twsocket@elists.org Sent: Friday, October 17, 2008 04:47 Subject: [twsocket] UDP Address Hello! I would like to know if its possible to get the address that a UDP packet comes from. I am making an application that will send multiple packets to different hosts using SendTo and I will be receiving replies from them. I have no power to change the protocol, so I need to know if its possible to find out the address each packet arrived from. Currently, I use bytesread := sock.Receive(@data, SizeOf(data)); to receive the data. where sock is a TWSocket object. sock.Addr will not work here.. :( Thanks for taking your time, - Martin E. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] UDP Address
Hello, Same result. PeerAddr will invoke the GetPeerAddr function: property PeerAddr : String read GetPeerAddr; Thanks for your timeso far. On Fri, Oct 17, 2008 at 5:25 AM, brian [EMAIL PROTECTED] wrote: Maybe GetPeerAddr? - Original Message - From: Xealot [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Friday, October 17, 2008 05:01 Subject: Re: [twsocket] UDP Address Thank you for replying, PeerAddr raises a SocketException 'Error 10057 in function GetPeerName Socket is not connected' Im assuming this is because I didnt actually run sock.Connect with the address I received that packet from? Im only running sock.connect once to avoid changing client port On Fri, Oct 17, 2008 at 4:54 AM, brian [EMAIL PROTECTED] wrote: Have you checked PeerAddr? - Original Message - From: Xealot [EMAIL PROTECTED] To: twsocket@elists.org Sent: Friday, October 17, 2008 04:47 Subject: [twsocket] UDP Address Hello! I would like to know if its possible to get the address that a UDP packet comes from. I am making an application that will send multiple packets to different hosts using SendTo and I will be receiving replies from them. I have no power to change the protocol, so I need to know if its possible to find out the address each packet arrived from. Currently, I use bytesread := sock.Receive(@data, SizeOf(data)); to receive the data. where sock is a TWSocket object. sock.Addr will not work here.. :( Thanks for taking your time, - Martin E. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] UDP Address
Hello Martin, Here is a small example: procedure TFoo.FUDPDataAvailable(Sender: TObject; Error: word); var Buffer: array [0..1023] of char; Len: integer; Src: TSockAddrIn; SrcLen: integer; begin SrcLen := SizeOf(Src); Len := TWSocket(Sender).ReceiveFrom(@Buffer, SizeOf(Buffer), Src, SrcLen); if Len 0 then Exit; Buffer[Len] := #0; {$ifdef DEBUG} WriteLn('UDP packet received from ', inet_ntoa(Src.sin_addr)); WriteLn('Data ', Buffer); --- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz Friday, October 17, 2008, 04:47, Xealot wrote: Hello! I would like to know if its possible to get the address that a UDP packet comes from. I am making an application that will send multiple packets to different hosts using SendTo and I will be receiving replies from them. I have no power to change the protocol, so I need to know if its possible to find out the address each packet arrived from. Currently, I use bytesread := sock.Receive(@data, SizeOf(data)); to receive the data. where sock is a TWSocket object. sock.Addr will not work here.. :( Thanks for taking your time, - Martin E. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] UDP Address
Thank you SO much. I really appreciate it. - Martin E. On Fri, Oct 17, 2008 at 7:37 AM, Wilfried Mestdagh [EMAIL PROTECTED]wrote: Hello Martin, Here is a small example: procedure TFoo.FUDPDataAvailable(Sender: TObject; Error: word); var Buffer: array [0..1023] of char; Len: integer; Src: TSockAddrIn; SrcLen: integer; begin SrcLen := SizeOf(Src); Len := TWSocket(Sender).ReceiveFrom(@Buffer, SizeOf(Buffer), Src, SrcLen); if Len 0 then Exit; Buffer[Len] := #0; {$ifdef DEBUG} WriteLn('UDP packet received from ', inet_ntoa(Src.sin_addr)); WriteLn('Data ', Buffer); --- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz Friday, October 17, 2008, 04:47, Xealot wrote: Hello! I would like to know if its possible to get the address that a UDP packet comes from. I am making an application that will send multiple packets to different hosts using SendTo and I will be receiving replies from them. I have no power to change the protocol, so I need to know if its possible to find out the address each packet arrived from. Currently, I use bytesread := sock.Receive(@data, SizeOf(data)); to receive the data. where sock is a TWSocket object. sock.Addr will not work here.. :( Thanks for taking your time, - Martin E. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be