Forum Topic - socket bind and prefix:
   
socket bind and prefix  
I use the io-net tcp stack startet like this, with prefix:
io-net -d rtl8169 -ptcpip prefix=/iopkt
SOCK=/iopkt ifconfig en0 192.168.1.10
When trying to bind a socket to address 192.168.1.10, bind fails with errno "Can't assign requested address".
I assume I have so specify the prefix somewhere.
Thanks in advance!
Thomas
Re: socket bind and prefix  
On Wed, Oct 29, 2008 at 01:55:22PM -0400, Thomas Zauner wrote:
> I use the io-net tcp stack startet like this, with prefix:
> io-net -d rtl8169 -ptcpip prefix=/iopkt
> SOCK=/iopkt ifconfig en0 192.168.1.10
> When trying to bind a socket to address 192.168.1.10, bind fails with errno "Can't assign requested address".
> I assume I have so specify the prefix somewhere.
> Thanks in advance!
> Thomas

You need to have the program doing the bind() inherit or
specify the same SOCK envar when doing the socket() call.

# SOCK=/iopkt myprog

-seanb
Re: socket bind and prefix  
Thanks, Sean and Robert.
My problem is: The system is equipped by my customer. They installed both io-net and io-pkt for the 2 network cards, as 
they did not get both adapters to run with io-pkt. I want to do UDP communication with the first adapter, and pcap with 
the second. If I specify SOCK, I can access only one adapter in my program.
Is it possible for a program to access 2 stacks at a time, or should my custerms try to set up io-pkt correctly for the 
2 adapters?

Thomas

(SOCK=/iopkt ifconfig returns one interface, and ifconfig returns the other interface)
(You are right, the network forum would have been better. I'll use it for the next related questions.)
Re: socket bind and prefix  
On Fri, Oct 31, 2008 at 05:25:05AM -0400, Thomas Zauner wrote:
> Thanks, Sean and Robert.
> My problem is: The system is equipped by my customer. They installed both io-net and io-pkt for the 2 network cards, 
as they did not get both adapters to run with io-pkt. I want to do UDP communication with the first adapter, and pcap 
with the second. If I specify SOCK, I can access only one adapter in my program.
> Is it possible for a program to access 2 stacks at a time, or should my custerms try to set up io-pkt correctly for 
the 2 adapters?

It's possible.  You'd have to clearenv(), setenv() SOCK as
required before each socket() call to target a particular
stack.  Or you could get a seed socket for each stack once
via the SOCK method, leave it open and do openfd() on them
as required which will get you a socket of the same domain,
type, protocol as the seed managed by the same stack.

-seanb
RE: socket bind and prefix  
Is the real reason for running io-net and io-pkt to get both adapters
working?  If so, then why not just run the io-net driver with the shim
in io-pkt?  The setenv definitely works.  I've done it in the past in
order to access two stacks (one doing data plane and one doing
management) in a single app.

	Robert.

-----Original Message-----
From: Sean Boudreau [mailto:community-noreply@qnx.com] 
Sent: Friday, October 31, 2008 8:59 AM
To: ostech-core_os
Subject: Re: socket bind and prefix

On Fri, Oct 31, 2008 at 05:25:05AM -0400, Thomas Zauner wrote:
> Thanks, Sean and Robert.
> My problem is: The system is equipped by my customer. They installed
both io-net and io-pkt for the 2 network cards, as they did not get both
adapters to run with io-pkt. I want to do UDP communication with the
first adapter, and pcap with the second. If I specify SOCK, I can access
only one adapter in my program.
> Is it possible for a program to access 2 stacks at a time, or should
my custerms try to set up io-pkt correctly for the 2 adapters?

It's possible.  You'd have to clearenv(), setenv() SOCK as
required before each socket() call to target a particular
stack.  Or you could get a seed socket for each stack once
via the SOCK method, leave it open and do openfd() on them
as required which will get you a socket of the same domain,
type, protocol as the seed managed by the same stack.

-seanb

_______________________________________________
OSTech
http://community.qnx.com/sf/go/post15785
RE: socket bind and prefix  
I'm a bit confused as to why you'd do the "prefix=/iopkt" with io-net.
If this is on 6.4, then io-net isn't present at all.

In any case, if you do

SOCK=/iopkt ifconfig

Does it report any interfaces at all?

	Robert.

P.S.  This question is best posted in the Networking forum rather than
an OS forum.

-----Original Message-----
From: Thomas Zauner [mailto:community-noreply@qnx.com] 
Sent: Wednesday, October 29, 2008 1:55 PM
To: ostech-core_os
Subject: socket bind and prefix

I use the io-net tcp stack startet like this, with prefix:
io-net -d rtl8169 -ptcpip prefix=/iopkt
SOCK=/iopkt ifconfig en0 192.168.1.10
When trying to bind a socket to address 192.168.1.10, bind fails with
errno "Can't assign requested address".
I assume I have so specify the prefix somewhere.
Thanks in advance!
Thomas


_______________________________________________
OSTech
http://community.qnx.com/sf/go/post15681