sockets not seeing the world :(

M

MoosePR

Hi

I have been programming for years but am just starting to develop
mobile apps for wm5. im using visual studio 2008, but did start my
development on visual studio 2003.

I am trying to implement some parts of an ftp client into a compact
app using sockets. Within vs2003 this worked fine both in an emulator
and running the app on a device via the activesync link, but when i
created a cab file for the app and installed it on my device it would
not connect to the network, failing on the connect command (connecting
to an endpoint)

I have since moved to vs2008 and i am now unable to get my application
to connect to the outside world both on the emulator and the device. I
have tried opening the web browser on the emulator and am unable to
access a web page, which tells me it has no internet connection. thats
fair enough i can see why that wont work but when i install the app
onto my device i have tried opening a normal data connection and wifi,
both allow me to open web pages, but neither allow my socket to
connect

anyone got any ideas??

Pete
 
P

Paul G. Tobey [eMVP]

You didn't tell us what sort of network we're talking about. There's also
the issue that, on a phone, when using the phone network to make your
network connections, that isn't connected 100% of the time. When you launch
the browser, it will try to connect, using the Connection Manager, to a
suitable network, including the phone network, if available, before actually
trying to open the page you're visiting.

So, I think what's going on is that basically you're trying to run an
outbound socket connection with no network adapter in the computer, if you
will. OpenNETCF, www.opennetcf.com, has a wrapper for the connection
manager which you can use to more-easily tell it to connect you to The
Internet (a network named that), so that you can access your server. If
you're using .NET CF 3.5, there's a built-in interface to it there.

Paul T.
 
M

MoosePR

yeah im setting up the endpoint and then connecting my socket to said
endpoint.

i thought there must be something that i would have to do to allow the
app to know which network connection to use. I was of course assuming
that the os would be clever enough to realize that an outgoing network
connection was trying to get out and therefore open up the default (3G
connection) or use the current (wireless/3G).

I am using VS2008 so i have the 3.5 framework available!! any example
code as to initializing the network adapter would be a great help if
it is not too much trouble!!!

Thanks for the reply

Pete
 
M

MoosePR

yeah im setting up the endpoint and then connecting my socket to said
endpoint.

i thought there must be something that i would have to do to allow the
app to know which network connection to use. I was of course assuming
that the os would be clever enough to realize that an outgoing network
connection was trying to get out and therefore open up the default (3G
connection) or use the current (wireless/3G).

I am using VS2008 so i have the 3.5 framework available!! any example
code as to initializing the network adapter would be a great help if
it is not too much trouble!!!

Thanks for the reply

Pete
 
P

Paul G. Tobey [eMVP]

Sorry, I'm a Windows CE guy, not really a Windows Mobile guy, so I don't
have Connection Manager samples laying around. Can't be that hard, though.
Check the .NET CF 3.5 help or do a search on MSDN.

Paul T.
 
S

Simon Hart [MVP]

You need to use the connection manager API. There is no managed wrapper in
the CF even in 3.5 so you'll have to code this yourself or use the SDF as
they have written a wrapper.

My advice is do *not* assume connection manager will make the right choice
of a connection for you. Use the GUID and select the network connection as
you know what connection it should be using. This is where the connection
manager falls flat not to mention there are some situations where it is
almost impossible for it to select the correct network connection profile.
 
M

MoosePR

Thanks For your input guys!!

If theres any sample code or if i can get some idea which part of the
msdn library to start reading with regards to selecting and
initialising a network connection on a compact framework device.

I have experience in using sockets but only on normal computers and so
they just use the current network connection

Thanks again

Pete
 
M

MoosePR

indeed you did and i have looked Paul. there is an ftp class and a
network class in there

The ftp doesnt seem to do anything like i was imagining. i was
expecting it to be a bit simpler (maybe me being lazy) theres no real
connect/auth/send/rec type functions in there and if it has to be done
manually i would be better off carrying on the way i was

Unless the network sockets type part of the openNETCF automatically
checks and opens connections as and when there needed that wont be
much use to me either.

I have asked the same thing on the msdn forums and a chappy on there
pointed me in the direction of the connection manager api. this
appears to do what i need to do although i can only find related code
in C++ not vb.net!! http://msdn2.microsoft.com/en-us/library/aa457829.aspx

All good fun

Pete
 
P

Paul G. Tobey [eMVP]

No, I'm not suggesting that you wrap the FTP stuff, but that you use the
Connection Manager wrapper in the Smart Device Framework to connect before
your FTP stuff does its thing.

Paul T.
 
S

Simon Hart [MVP]

I'm not sure what you are looking for. It is pretty easy to figure out ie:

ConnectionManager connectionManager = new ConnectionManager();
connectionManager.Connect(guid, false,
OpenNETCF.Net.ConnectionMode.Asynchronous);

Where guid is your network connection. Get this by either iterating existing
networks using the ConnectionManager wrappr OpenNETCF provide or use the one
you have allocated when creating your own network.
 
S

Simon Hart [MVP]

I will create a blog on this as creating a network then using
connectionmanager isn't massively documented. I'll do this when I get back to
the UK.
 
M

MoosePR

I tried to get the open net framework and install it but when i get
the source it says that it will only install correctly on an english
version of visual studio 2003 (this will only install successfully if
you have the English version of Visual Studio .NET 2003 installed.). i
have 2008 has anyone any experience on this???

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top