Unix Programming - sendto () and recvfrom() with the same IP address

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2006 > sendto () and recvfrom() with the same IP address





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author sendto () and recvfrom() with the same IP address
Alex Vinokur

2006-04-02, 7:41 pm

UDP Socket

socket1: ip1, port1
socket2: ip2, port2

ip1 == ip2
port1 != port2

----------------------------------
sendto () // From socket1 to (ip2, port2)
recvfrom() // On socket2
---------------------------------

Is that legal?
In my application a message has been sent via sendto(), but recvfrom()
is waiting for a message (blocked).

Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Barry Margolin

2006-04-02, 7:41 pm

In article <1143456930.312146.320360@z34g2000cwc.googlegroups.com>,
"Alex Vinokur" <alexvn@users.sourceforge.net> wrote:

> UDP Socket
>
> socket1: ip1, port1
> socket2: ip2, port2
>
> ip1 == ip2
> port1 != port2
>
> ----------------------------------
> sendto () // From socket1 to (ip2, port2)
> recvfrom() // On socket2
> ---------------------------------
>
> Is that legal?


Yes. For instance, if you're running a DNS server on your machine, you
can query it.

> In my application a message has been sent via sendto(), but recvfrom()
> is waiting for a message (blocked).


Sounds like you've done something wrong in your code. Another
possibility is ipfw rules that are blocking the packets.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Alex Vinokur

2006-04-02, 7:41 pm


Barry Margolin wrote:
> In article <1143456930.312146.320360@z34g2000cwc.googlegroups.com>,
> "Alex Vinokur" <alexvn@users.sourceforge.net> wrote:
>
>
> Yes. For instance, if you're running a DNS server on your machine, you
> can query it.


The program is implemented in INTEGRITY RTOS and runs on Target PowerPC
8260.
I am not sure that the a DNS server is running on the Target.
What is going in this case with sendto () and recvfrom() from my
question?

>
>
> Sounds like you've done something wrong in your code. Another
> possibility is ipfw rules that are blocking the packets.
>


How can we know that?

[snip]

Thanks,

Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

David Schwartz

2006-04-02, 7:42 pm


"Alex Vinokur" <alexvn@users.sourceforge.net> wrote in message
news:1143456930.312146.320360@z34g2000cwc.googlegroups.com...

> UDP Socket
>
> socket1: ip1, port1
> socket2: ip2, port2
>
> ip1 == ip2
> port1 != port2
>
> ----------------------------------
> sendto () // From socket1 to (ip2, port2)
> recvfrom() // On socket2
> ---------------------------------
>
> Is that legal?


Yes.

> In my application a message has been sent via sendto(), but recvfrom()
> is waiting for a message (blocked).


UDP loses messages sometimes. (Or you might have a bug.)

DS


Barry Margolin

2006-04-02, 7:42 pm

In article <1143459906.606302.221980@i39g2000cwa.googlegroups.com>,
"Alex Vinokur" <alexvn@users.sourceforge.net> wrote:

> Barry Margolin wrote:
>
> The program is implemented in INTEGRITY RTOS and runs on Target PowerPC
> 8260.


Is that Unix? If not, what's the point of asking in a Unix newsgroup?
Maybe you should ask Integrity tech support.

> I am not sure that the a DNS server is running on the Target.


So? I was just giving an example of a UDP-based application that we
know works when the sender and receiver are on the same IP.

> What is going in this case with sendto () and recvfrom() from my
> question?
>
>
> How can we know that?


Know what? That you've done something wrong in your code? Maybe if you
post a minimal example that demonstrates the problem.

If you mean ipfw, look at the firewall rules that are configured on the
system (does Integrity RTOS even have IPFW?).

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Geoff Clare

2006-04-02, 7:42 pm

Barry Margolin <barmar@alum.mit.edu> wrote, on Mon, 27 Mar 2006:

>
> Is that Unix? If not, what's the point of asking in a Unix newsgroup?


It's not UNIX, but it is POSIX conformant, so this is the right
newsgroup.

In fact INTEGRITY 5.0 is the only system certified to just the POSIX
conformance requirements of POSIX.1-2001 so far (AIX 5L and Solaris 10
are certified to the UNIX conformance requirements of POSIX.1-2001/SUSv3).

http://get.posixcertified.ieee.org/cert_prodlist.tpl

--
Geoff Clare <netnews@gclare.org.uk>

Jim Cochrane

2006-04-02, 7:42 pm

On 2006-03-28, Barry Margolin <barmar@alum.mit.edu> wrote:
> In article <1143459906.606302.221980@i39g2000cwa.googlegroups.com>,
> "Alex Vinokur" <alexvn@users.sourceforge.net> wrote:
>
>
> Know what? That you've done something wrong in your code? Maybe if you
> post a minimal example that demonstrates the problem.


Another common (hopefully) way of determining if a piece of code has a bug
is to perform a code inspection (
http://en.wikipedia.org/wiki/Software_inspection
).


--

*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
Alex Vinokur

2006-04-02, 7:42 pm

Jim Cochrane wrote:
> On 2006-03-28, Barry Margolin <barmar@alum.mit.edu> wrote:


[snip]

>
>
> Another common (hopefully) way of determining if a piece of code has a bug
> is to perform a code inspection (
> http://en.wikipedia.org/wiki/Software_inspection
> ).


[snip]

My full program (C++ for INTEGRITY RROS) contains almost 400 rows
(ping-function, pong-function, etc).
It seems that it is impossible to send it to comp.unix.programmer.
But I can send the program to other Google that is managed by me.

Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Alex Vinokur

2006-04-27, 7:56 am


Alex Vinokur wrote:
> UDP Socket
>
> socket1: ip1, port1
> socket2: ip2, port2
>
> ip1 == ip2
> port1 != port2
>
> ----------------------------------
> sendto () // From socket1 to (ip2, port2)
> recvfrom() // On socket2
> ---------------------------------
>
> Is that legal?
> In my application a message has been sent via sendto(), but recvfrom()
> is waiting for a message (blocked).
>


[snip]

That works if ip1 == ip2 == 127.0.0.1, i.e.,
a message has been sent by using sendto() via socket1,
and it has been received by using recvfrom() via socket2.

That doesn't work if ip1/ip2 != 127.0.0.1,
for instance, if ip1 == ip2 == 10.1.1.1,
a message has been sent by using sendto() via socket1,
but recvfrom() on socket2 is waiting for a message (blocked).

What could cause the problem?
I need ip1 == ip2 == 10.1.1.1 and working socket1 and socket2.


Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com