Click here to get back home

GPRS/EDGE passive data connection Problem!

 HomeNewsGroups | Search | About
 microsoft.public.smartphone.developer    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
GPRS/EDGE passive data connection Problem! jerome 06-02-2006
Posted by jerome on June 2, 2006, 5:31 am
Please log in for more thread options
hi all;

I have a problem when i use a EDGE/GPRS connection. Sometimes it works fine,
but sometimes there is a problem.

I use the connection manager to connect my smarpthone by gprs, and when i'm
connected, I log in to a ftp server. After this, I send pictures by upload to
this server with the OpenNetCF librairy. But sometimes, i have this error :

"couldn't open passive data connection, no DataConnection IP was given."

Is someone know this problem ?

I use in this order:

if there are pictures to send
ConnectGPRS();
FTPLogin()
foreach( pictures in PicturesDirectory)
SendFiles(pictures) // here's the problem, not all the pictures are
sent
FTPLogout();
Disconnect();

Sometimes it works for the first and the third picture, sometimes just for
the first, sometimes for the second ...

Here's a part of my code:
public bool connectGPRS()
{
label1.Text = connMgr.Status.ToString();


DestinationInfoCollection DIC = connMgr.EnumDestinations();
long startTime;
bool is_connected = false;
try
{
foreach (DestinationInfo di in DIC)
{

if (di.description == "Internet")
{
int i = 0;
while (connMgr.Status.ToString() != "Connected" &
i<10)

{
connMgr.Connect(di.guid, true,
ConnectionMode.Asynch
ronous)

startTime = DateTime.Now.Ticks;
while ((!is_connected) & (DateTime.Now.Ticks -
start
Time < 20 * TimeSpan.TicksPerSecond))
{
if (connMgr.Status.ToString() ==
"Connected") is
_connected = true;
}
i++;
}
label1.Text = connMgr.Status.ToString();

}

}

}
catch (SystemException err)
{
MessageBox.Show(" err 700 " + err.Message);
return false;
}
return true;
}


public bool FTPLogin()
{
label1.Text = "try to login";
try
{
FtpRequestCreator creator = new FtpRequestCreator();
WebRequest.RegisterPrefix("ftp:", creator);
//Building our URI object
Uri testUri;
// Building our URI object

testUri = new Uri("ftp://10.3.3.42");

//Creating a new FtbRequest object
request = (FtpWebRequest)WebRequest.Create(testUri);

request.Credentials = new NetworkCredential("any", "any");

//Getting the Request stream
ftpRequestStream = request.GetRequestStream();


StreamReader reader = new StreamReader(ftpRequestStream);
string responseFTP = reader.ReadToEnd();
label1.Text = responseFTP;
//Connected
logined = true;
label1.Text = "logined";

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
return true;
}
public bool SendFile(string PhotoPath)
{
progress.Text = "";
progressBar1.Value = 0;
label1.Text = "try to send";
string LocalFilePathText = PhotoPath;
string PhotoName = Path.GetFileName(PhotoPath);
string RemoteFilePathText = "\GSM\" + PhotoName;

/*string LocalFilePathText = "\My Documents\My
Pictures\test.txt"
;
string RemoteFilePathText = "\test.txt";*/

StreamReader Reader;
String commandReply;

try
{

// Open the input file. If the file does not exist, it's an
// error.
FileStream fs = new FileStream(LocalFilePathText,
FileMode.Open)
;

// Create the reader for the local file data.
BinaryReader r = new BinaryReader(fs);
label1.Text = "file opened";
// Opening the data connection, this must be done before
// we issue the command.
Stream ftpResponseStream =
request.GetResponse().GetResponseStre
am();
label1.Text = "bordel1";
BinaryWriter response = new BinaryWriter(ftpResponseStream);

// Prepare to send commands to the server.
StreamWriter writer = new StreamWriter(ftpRequestStream);
label1.Text = "bordel2";
// Set transfer type to IMAGE (binary).
writer.Write("TYPE I\r\n");
writer.Flush();
...
...
....





Similar ThreadsPosted
wi-fi ad hoc connection problem March 29, 2007, 2:42 am
who encountered that DATA ABORT problem? October 18, 2005, 5:07 pm
What connection type Connection Manager chose? December 19, 2006, 8:21 am
Connection Manager and Connection Flags August 24, 2005, 10:00 pm
Connection manager July 25, 2005, 7:08 am
Cannot use pIE via wifi connection June 7, 2006, 10:38 pm
How to get connection type? June 9, 2007, 4:26 am
Obex Asynchroneous Connection June 1, 2005, 5:04 am
Detection of USB cable connection June 28, 2005, 6:35 am
How to create my own gprs connection October 3, 2005, 10:17 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap