Doesn't make sense at all.......send/recv in socket...

G

Guest

Hi,

It makes me crazy.......I can't figure it out why it is happening at
all...so strange..
Here is the how system works...

Development environment.

Client : .NET Compact Framework 2.0/PPC
Server: .NET Framework 2.0

PPC connects to the server to transfer a file.

Client code in PPC
As you can guess, fs is FileStream.

---
byte[] buf = new buffer[8192];
int bytRead = fs.Read(buf, 0, buf.Length);
while (bytRead > 0)
{
_socket.Send(buf, 0, bytRead, SocketFlags.None);
bytRead = fs.Read(buf, 0, buf.Length);
}
_socket.Close();

---

Server code in the desktop
fs is FileStream.

---

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);

} while ( rBytes > 0 );

client.Close();

---------------

When I tested these, it works perfectly under Wireless connection.
HOWEVER, the problem arise when testing this with the cradled device.
With the cradled device, the server ONLY receives 99% data. For example, if
I send a file (162KB) from the PPC, the server ONLY receives 161KB.
I tried to fix possible soultions as best as I can...However, I can't figure
out how this works WITH THE CRADLED device.
Once I take off the device from the cradle, then test under wireless
connection, it WORKS perfectly.....
It is so strange......Why the server ONLY receives 99% when the PPC
cradles?????

Any help would be appreciated.

Thanks,

...........................................................TJ
 
P

Paul G. Tobey [eMVP]

You need to call Socket.Shutdown() before calling Close to assure that all
buffered data is sent before the socket is abandoned.

Paul T.
 
G

Guest

Yes, I did, but it still has same problem.

_socket.Shutdown(SocketShutdown.Both);
_socket.Close();

I just forgot to paste it...

Thanks,

.........................................TJ

Paul G. Tobey said:
You need to call Socket.Shutdown() before calling Close to assure that all
buffered data is sent before the socket is abandoned.

Paul T.

TJ said:
Hi,

It makes me crazy.......I can't figure it out why it is happening at
all...so strange..
Here is the how system works...

Development environment.

Client : .NET Compact Framework 2.0/PPC
Server: .NET Framework 2.0

PPC connects to the server to transfer a file.

Client code in PPC
As you can guess, fs is FileStream.

---
byte[] buf = new buffer[8192];
int bytRead = fs.Read(buf, 0, buf.Length);
while (bytRead > 0)
{
_socket.Send(buf, 0, bytRead, SocketFlags.None);
bytRead = fs.Read(buf, 0, buf.Length);
}
_socket.Close();

---

Server code in the desktop
fs is FileStream.

---

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);

} while ( rBytes > 0 );

client.Close();

---------------

When I tested these, it works perfectly under Wireless connection.
HOWEVER, the problem arise when testing this with the cradled device.
With the cradled device, the server ONLY receives 99% data. For example,
if
I send a file (162KB) from the PPC, the server ONLY receives 161KB.
I tried to fix possible soultions as best as I can...However, I can't
figure
out how this works WITH THE CRADLED device.
Once I take off the device from the cradle, then test under wireless
connection, it WORKS perfectly.....
It is so strange......Why the server ONLY receives 99% when the PPC
cradles?????

Any help would be appreciated.

Thanks,

..........................................................TJ
 
P

Paul G. Tobey [eMVP]

Have you tried adding some delay time after the last send and before
Shutdown or after Shutdown and before Close?

Paul T.

TJ said:
Yes, I did, but it still has same problem.

_socket.Shutdown(SocketShutdown.Both);
_socket.Close();

I just forgot to paste it...

Thanks,

........................................TJ

Paul G. Tobey said:
You need to call Socket.Shutdown() before calling Close to assure that
all
buffered data is sent before the socket is abandoned.

Paul T.

TJ said:
Hi,

It makes me crazy.......I can't figure it out why it is happening at
all...so strange..
Here is the how system works...

Development environment.

Client : .NET Compact Framework 2.0/PPC
Server: .NET Framework 2.0

PPC connects to the server to transfer a file.

Client code in PPC
As you can guess, fs is FileStream.

---
byte[] buf = new buffer[8192];
int bytRead = fs.Read(buf, 0, buf.Length);
while (bytRead > 0)
{
_socket.Send(buf, 0, bytRead, SocketFlags.None);
bytRead = fs.Read(buf, 0, buf.Length);
}
_socket.Close();

---

Server code in the desktop
fs is FileStream.

---

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);

} while ( rBytes > 0 );

client.Close();

---------------

When I tested these, it works perfectly under Wireless connection.
HOWEVER, the problem arise when testing this with the cradled device.
With the cradled device, the server ONLY receives 99% data. For
example,
if
I send a file (162KB) from the PPC, the server ONLY receives 161KB.
I tried to fix possible soultions as best as I can...However, I can't
figure
out how this works WITH THE CRADLED device.
Once I take off the device from the cradle, then test under wireless
connection, it WORKS perfectly.....
It is so strange......Why the server ONLY receives 99% when the PPC
cradles?????

Any help would be appreciated.

Thanks,

..........................................................TJ
 
G

Guest

Hi,

No, I haven' tried it yet. I'll let you know how it goes...
BTW, could it be reliable solution by adding some delay?
Also, could you think of why this strange thing happens ONLY when the PPC
device cradles?

Thanks,

............................................TJ

Paul G. Tobey said:
Have you tried adding some delay time after the last send and before
Shutdown or after Shutdown and before Close?

Paul T.

TJ said:
Yes, I did, but it still has same problem.

_socket.Shutdown(SocketShutdown.Both);
_socket.Close();

I just forgot to paste it...

Thanks,

........................................TJ

Paul G. Tobey said:
You need to call Socket.Shutdown() before calling Close to assure that
all
buffered data is sent before the socket is abandoned.

Paul T.

Hi,

It makes me crazy.......I can't figure it out why it is happening at
all...so strange..
Here is the how system works...

Development environment.

Client : .NET Compact Framework 2.0/PPC
Server: .NET Framework 2.0

PPC connects to the server to transfer a file.

Client code in PPC
As you can guess, fs is FileStream.

---
byte[] buf = new buffer[8192];
int bytRead = fs.Read(buf, 0, buf.Length);
while (bytRead > 0)
{
_socket.Send(buf, 0, bytRead, SocketFlags.None);
bytRead = fs.Read(buf, 0, buf.Length);
}
_socket.Close();

---

Server code in the desktop
fs is FileStream.

---

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);

} while ( rBytes > 0 );

client.Close();

---------------

When I tested these, it works perfectly under Wireless connection.
HOWEVER, the problem arise when testing this with the cradled device.
With the cradled device, the server ONLY receives 99% data. For
example,
if
I send a file (162KB) from the PPC, the server ONLY receives 161KB.
I tried to fix possible soultions as best as I can...However, I can't
figure
out how this works WITH THE CRADLED device.
Once I take off the device from the cradle, then test under wireless
connection, it WORKS perfectly.....
It is so strange......Why the server ONLY receives 99% when the PPC
cradles?????

Any help would be appreciated.

Thanks,

..........................................................TJ
 
G

Guest

Hi,

Unfortunately, no it didn't work...
PPC sent every data(As far as I see the staus of PPC), again, the server
received 99%, then still waiting more data....in cradle PPC......

I also tried to send ack from server, like this....

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);
if(fs.Length == expectedSizeIneedtoreceive) {
break;
}
} while ( rBytes > 0 );

client.Send(ackBuffer,ackBuffer.Length...);

When PPC is cradled, the loop never exit........strange........
However, like I said, it works fine in the wireless connection.

Thanks,

.........................................................TJ

TJ said:
Hi,

No, I haven' tried it yet. I'll let you know how it goes...
BTW, could it be reliable solution by adding some delay?
Also, could you think of why this strange thing happens ONLY when the PPC
device cradles?

Thanks,

...........................................TJ

Paul G. Tobey said:
Have you tried adding some delay time after the last send and before
Shutdown or after Shutdown and before Close?

Paul T.

TJ said:
Yes, I did, but it still has same problem.

_socket.Shutdown(SocketShutdown.Both);
_socket.Close();

I just forgot to paste it...

Thanks,

........................................TJ

:

You need to call Socket.Shutdown() before calling Close to assure that
all
buffered data is sent before the socket is abandoned.

Paul T.

Hi,

It makes me crazy.......I can't figure it out why it is happening at
all...so strange..
Here is the how system works...

Development environment.

Client : .NET Compact Framework 2.0/PPC
Server: .NET Framework 2.0

PPC connects to the server to transfer a file.

Client code in PPC
As you can guess, fs is FileStream.

---
byte[] buf = new buffer[8192];
int bytRead = fs.Read(buf, 0, buf.Length);
while (bytRead > 0)
{
_socket.Send(buf, 0, bytRead, SocketFlags.None);
bytRead = fs.Read(buf, 0, buf.Length);
}
_socket.Close();

---

Server code in the desktop
fs is FileStream.

---

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);

} while ( rBytes > 0 );

client.Close();

---------------

When I tested these, it works perfectly under Wireless connection.
HOWEVER, the problem arise when testing this with the cradled device.
With the cradled device, the server ONLY receives 99% data. For
example,
if
I send a file (162KB) from the PPC, the server ONLY receives 161KB.
I tried to fix possible soultions as best as I can...However, I can't
figure
out how this works WITH THE CRADLED device.
Once I take off the device from the cradle, then test under wireless
connection, it WORKS perfectly.....
It is so strange......Why the server ONLY receives 99% when the PPC
cradles?????

Any help would be appreciated.

Thanks,

..........................................................TJ
 
P

Paul G. Tobey [eMVP]

You should take a look at the archives and see if this hasn't come up
before. It seems to me that we would have seen it before, if it was this
sure to happen. There's no chance that the client really isn't sending the
number of bytes that it said it was going to (or however you're
communicating to the server on the PC how much data it should expect)?

http://groups.google.com/group/micr...ork/topics?hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8

It might also be valuable to someone following this thread to know *which*
Pocket PC and what Windows Mobile version it's running...

Paul T.

TJ said:
Hi,

Unfortunately, no it didn't work...
PPC sent every data(As far as I see the staus of PPC), again, the server
received 99%, then still waiting more data....in cradle PPC......

I also tried to send ack from server, like this....

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);
if(fs.Length == expectedSizeIneedtoreceive) {
break;
}
} while ( rBytes > 0 );

client.Send(ackBuffer,ackBuffer.Length...);

When PPC is cradled, the loop never exit........strange........
However, like I said, it works fine in the wireless connection.

Thanks,

........................................................TJ

TJ said:
Hi,

No, I haven' tried it yet. I'll let you know how it goes...
BTW, could it be reliable solution by adding some delay?
Also, could you think of why this strange thing happens ONLY when the PPC
device cradles?

Thanks,

...........................................TJ

Paul G. Tobey said:
Have you tried adding some delay time after the last send and before
Shutdown or after Shutdown and before Close?

Paul T.

Yes, I did, but it still has same problem.

_socket.Shutdown(SocketShutdown.Both);
_socket.Close();

I just forgot to paste it...

Thanks,

........................................TJ

:

You need to call Socket.Shutdown() before calling Close to assure
that
all
buffered data is sent before the socket is abandoned.

Paul T.

Hi,

It makes me crazy.......I can't figure it out why it is happening
at
all...so strange..
Here is the how system works...

Development environment.

Client : .NET Compact Framework 2.0/PPC
Server: .NET Framework 2.0

PPC connects to the server to transfer a file.

Client code in PPC
As you can guess, fs is FileStream.

---
byte[] buf = new buffer[8192];
int bytRead = fs.Read(buf, 0, buf.Length);
while (bytRead > 0)
{
_socket.Send(buf, 0, bytRead, SocketFlags.None);
bytRead = fs.Read(buf, 0, buf.Length);
}
_socket.Close();

---

Server code in the desktop
fs is FileStream.

---

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);

} while ( rBytes > 0 );

client.Close();

---------------

When I tested these, it works perfectly under Wireless connection.
HOWEVER, the problem arise when testing this with the cradled
device.
With the cradled device, the server ONLY receives 99% data. For
example,
if
I send a file (162KB) from the PPC, the server ONLY receives
161KB.
I tried to fix possible soultions as best as I can...However, I
can't
figure
out how this works WITH THE CRADLED device.
Once I take off the device from the cradle, then test under
wireless
connection, it WORKS perfectly.....
It is so strange......Why the server ONLY receives 99% when the
PPC
cradles?????

Any help would be appreciated.

Thanks,

..........................................................TJ
 
G

Guest

I've searched something on the google to find out this similar issue...However,
I wasn't able to find out so far................
Maybe delay was something best suggesstion for this issue on the
net...though it didn't work..

The PPC model I am using is ViewSonic Pocket PC.
Windows Mobile 2003 Second Edition Version 4.21.1088

So how do I make my PPC client so that it is guarantee to send every data to
the server?
(I believe that I can check the return value of Send method...however, I
don't think that it is also guaranteed to deliever to the server...)
Why it is working in the wirless connection?
Is it something different going on if the PPC is in the cradle..??

Thanks,


Paul G. Tobey said:
You should take a look at the archives and see if this hasn't come up
before. It seems to me that we would have seen it before, if it was this
sure to happen. There's no chance that the client really isn't sending the
number of bytes that it said it was going to (or however you're
communicating to the server on the PC how much data it should expect)?

http://groups.google.com/group/micr...ork/topics?hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8

It might also be valuable to someone following this thread to know *which*
Pocket PC and what Windows Mobile version it's running...

Paul T.

TJ said:
Hi,

Unfortunately, no it didn't work...
PPC sent every data(As far as I see the staus of PPC), again, the server
received 99%, then still waiting more data....in cradle PPC......

I also tried to send ack from server, like this....

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);
if(fs.Length == expectedSizeIneedtoreceive) {
break;
}
} while ( rBytes > 0 );

client.Send(ackBuffer,ackBuffer.Length...);

When PPC is cradled, the loop never exit........strange........
However, like I said, it works fine in the wireless connection.

Thanks,

........................................................TJ

TJ said:
Hi,

No, I haven' tried it yet. I'll let you know how it goes...
BTW, could it be reliable solution by adding some delay?
Also, could you think of why this strange thing happens ONLY when the PPC
device cradles?

Thanks,

...........................................TJ

:

Have you tried adding some delay time after the last send and before
Shutdown or after Shutdown and before Close?

Paul T.

Yes, I did, but it still has same problem.

_socket.Shutdown(SocketShutdown.Both);
_socket.Close();

I just forgot to paste it...

Thanks,

........................................TJ

:

You need to call Socket.Shutdown() before calling Close to assure
that
all
buffered data is sent before the socket is abandoned.

Paul T.

Hi,

It makes me crazy.......I can't figure it out why it is happening
at
all...so strange..
Here is the how system works...

Development environment.

Client : .NET Compact Framework 2.0/PPC
Server: .NET Framework 2.0

PPC connects to the server to transfer a file.

Client code in PPC
As you can guess, fs is FileStream.

---
byte[] buf = new buffer[8192];
int bytRead = fs.Read(buf, 0, buf.Length);
while (bytRead > 0)
{
_socket.Send(buf, 0, bytRead, SocketFlags.None);
bytRead = fs.Read(buf, 0, buf.Length);
}
_socket.Close();

---

Server code in the desktop
fs is FileStream.

---

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);

} while ( rBytes > 0 );

client.Close();

---------------

When I tested these, it works perfectly under Wireless connection.
HOWEVER, the problem arise when testing this with the cradled
device.
With the cradled device, the server ONLY receives 99% data. For
example,
if
I send a file (162KB) from the PPC, the server ONLY receives
161KB.
I tried to fix possible soultions as best as I can...However, I
can't
figure
out how this works WITH THE CRADLED device.
Once I take off the device from the cradle, then test under
wireless
connection, it WORKS perfectly.....
It is so strange......Why the server ONLY receives 99% when the
PPC
cradles?????

Any help would be appreciated.

Thanks,

..........................................................TJ
 
P

Paul G. Tobey [eMVP]

No, send() just indicates that the data has been queued. You *should* be
checking all return values from all socket calls, as they all return
meaningful information, but I wouldn't expect, given the symptoms found so
far, that you'll find anything amiss. Check them, though; there's no reason
not to look for an easy solution like that.

It's working in the wireless connection because it should work. You're
either running into a previously-undetected (maybe, or maybe you just
haven't found it yet), problem, or the differences between the WiFi
connection and ActiveSync are exposing a problem that we just haven't
spotted in your code. Keep looking...

Paul T.

TJ said:
I've searched something on the google to find out this similar
issue...However,
I wasn't able to find out so far................
Maybe delay was something best suggesstion for this issue on the
net...though it didn't work..

The PPC model I am using is ViewSonic Pocket PC.
Windows Mobile 2003 Second Edition Version 4.21.1088

So how do I make my PPC client so that it is guarantee to send every data
to
the server?
(I believe that I can check the return value of Send method...however, I
don't think that it is also guaranteed to deliever to the server...)
Why it is working in the wirless connection?
Is it something different going on if the PPC is in the cradle..??

Thanks,


Paul G. Tobey said:
You should take a look at the archives and see if this hasn't come up
before. It seems to me that we would have seen it before, if it was this
sure to happen. There's no chance that the client really isn't sending
the
number of bytes that it said it was going to (or however you're
communicating to the server on the PC how much data it should expect)?

http://groups.google.com/group/micr...ork/topics?hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8

It might also be valuable to someone following this thread to know
*which*
Pocket PC and what Windows Mobile version it's running...

Paul T.

TJ said:
Hi,

Unfortunately, no it didn't work...
PPC sent every data(As far as I see the staus of PPC), again, the
server
received 99%, then still waiting more data....in cradle PPC......

I also tried to send ack from server, like this....

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);
if(fs.Length == expectedSizeIneedtoreceive) {
break;
}
} while ( rBytes > 0 );

client.Send(ackBuffer,ackBuffer.Length...);

When PPC is cradled, the loop never exit........strange........
However, like I said, it works fine in the wireless connection.

Thanks,

........................................................TJ

:

Hi,

No, I haven' tried it yet. I'll let you know how it goes...
BTW, could it be reliable solution by adding some delay?
Also, could you think of why this strange thing happens ONLY when the
PPC
device cradles?

Thanks,

...........................................TJ

:

Have you tried adding some delay time after the last send and before
Shutdown or after Shutdown and before Close?

Paul T.

Yes, I did, but it still has same problem.

_socket.Shutdown(SocketShutdown.Both);
_socket.Close();

I just forgot to paste it...

Thanks,

........................................TJ

:

You need to call Socket.Shutdown() before calling Close to assure
that
all
buffered data is sent before the socket is abandoned.

Paul T.

Hi,

It makes me crazy.......I can't figure it out why it is
happening
at
all...so strange..
Here is the how system works...

Development environment.

Client : .NET Compact Framework 2.0/PPC
Server: .NET Framework 2.0

PPC connects to the server to transfer a file.

Client code in PPC
As you can guess, fs is FileStream.

---
byte[] buf = new buffer[8192];
int bytRead = fs.Read(buf, 0, buf.Length);
while (bytRead > 0)
{
_socket.Send(buf, 0, bytRead, SocketFlags.None);
bytRead = fs.Read(buf, 0, buf.Length);
}
_socket.Close();

---

Server code in the desktop
fs is FileStream.

---

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length,
SocketFlags.None);
fs.Write(buf, 0, rBytes);

} while ( rBytes > 0 );

client.Close();

---------------

When I tested these, it works perfectly under Wireless
connection.
HOWEVER, the problem arise when testing this with the cradled
device.
With the cradled device, the server ONLY receives 99% data. For
example,
if
I send a file (162KB) from the PPC, the server ONLY receives
161KB.
I tried to fix possible soultions as best as I can...However, I
can't
figure
out how this works WITH THE CRADLED device.
Once I take off the device from the cradle, then test under
wireless
connection, it WORKS perfectly.....
It is so strange......Why the server ONLY receives 99% when the
PPC
cradles?????

Any help would be appreciated.

Thanks,

..........................................................TJ
 
G

Guest

Yeap,

I've changed a little bit to check the return value(Send and Receive)...If
it wasn't sent or received what it was supposed to, the operation was
retried. However, as you probably can guess, no luck.

The real problem is that, for example, send, it returns the size of buffer
that I was supposed to send,
but at the sever side, no data coming, so I wasn't even able to check the
return value of receive...
Since I use the blocked socket, it just hangs on the receive.....I don't
have a plan to change it to async. (Actually, I tried async, but same
problem).

At this momemnt, the best thing I can GUESS is that somehow data is dropped
in Active Sync(Cradled device).................

Does anybody have any idea for this?

Thanks,

..........................................................TJ

Paul G. Tobey said:
No, send() just indicates that the data has been queued. You *should* be
checking all return values from all socket calls, as they all return
meaningful information, but I wouldn't expect, given the symptoms found so
far, that you'll find anything amiss. Check them, though; there's no reason
not to look for an easy solution like that.

It's working in the wireless connection because it should work. You're
either running into a previously-undetected (maybe, or maybe you just
haven't found it yet), problem, or the differences between the WiFi
connection and ActiveSync are exposing a problem that we just haven't
spotted in your code. Keep looking...

Paul T.

TJ said:
I've searched something on the google to find out this similar
issue...However,
I wasn't able to find out so far................
Maybe delay was something best suggesstion for this issue on the
net...though it didn't work..

The PPC model I am using is ViewSonic Pocket PC.
Windows Mobile 2003 Second Edition Version 4.21.1088

So how do I make my PPC client so that it is guarantee to send every data
to
the server?
(I believe that I can check the return value of Send method...however, I
don't think that it is also guaranteed to deliever to the server...)
Why it is working in the wirless connection?
Is it something different going on if the PPC is in the cradle..??

Thanks,


Paul G. Tobey said:
You should take a look at the archives and see if this hasn't come up
before. It seems to me that we would have seen it before, if it was this
sure to happen. There's no chance that the client really isn't sending
the
number of bytes that it said it was going to (or however you're
communicating to the server on the PC how much data it should expect)?

http://groups.google.com/group/micr...ork/topics?hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8

It might also be valuable to someone following this thread to know
*which*
Pocket PC and what Windows Mobile version it's running...

Paul T.

Hi,

Unfortunately, no it didn't work...
PPC sent every data(As far as I see the staus of PPC), again, the
server
received 99%, then still waiting more data....in cradle PPC......

I also tried to send ack from server, like this....

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length, SocketFlags.None);
fs.Write(buf, 0, rBytes);
if(fs.Length == expectedSizeIneedtoreceive) {
break;
}
} while ( rBytes > 0 );

client.Send(ackBuffer,ackBuffer.Length...);

When PPC is cradled, the loop never exit........strange........
However, like I said, it works fine in the wireless connection.

Thanks,

........................................................TJ

:

Hi,

No, I haven' tried it yet. I'll let you know how it goes...
BTW, could it be reliable solution by adding some delay?
Also, could you think of why this strange thing happens ONLY when the
PPC
device cradles?

Thanks,

...........................................TJ

:

Have you tried adding some delay time after the last send and before
Shutdown or after Shutdown and before Close?

Paul T.

Yes, I did, but it still has same problem.

_socket.Shutdown(SocketShutdown.Both);
_socket.Close();

I just forgot to paste it...

Thanks,

........................................TJ

:

You need to call Socket.Shutdown() before calling Close to assure
that
all
buffered data is sent before the socket is abandoned.

Paul T.

Hi,

It makes me crazy.......I can't figure it out why it is
happening
at
all...so strange..
Here is the how system works...

Development environment.

Client : .NET Compact Framework 2.0/PPC
Server: .NET Framework 2.0

PPC connects to the server to transfer a file.

Client code in PPC
As you can guess, fs is FileStream.

---
byte[] buf = new buffer[8192];
int bytRead = fs.Read(buf, 0, buf.Length);
while (bytRead > 0)
{
_socket.Send(buf, 0, bytRead, SocketFlags.None);
bytRead = fs.Read(buf, 0, buf.Length);
}
_socket.Close();

---

Server code in the desktop
fs is FileStream.

---

int rBytes = 0;
byte[] buf = new byte[8192];
do
{
rBytes = client.Receive(buf, 0, buf.Length,
SocketFlags.None);
fs.Write(buf, 0, rBytes);

} while ( rBytes > 0 );

client.Close();

---------------

When I tested these, it works perfectly under Wireless
connection.
HOWEVER, the problem arise when testing this with the cradled
device.
With the cradled device, the server ONLY receives 99% data. For
example,
if
I send a file (162KB) from the PPC, the server ONLY receives
161KB.
I tried to fix possible soultions as best as I can...However, I
can't
figure
out how this works WITH THE CRADLED device.
Once I take off the device from the cradle, then test under
wireless
connection, it WORKS perfectly.....
It is so strange......Why the server ONLY receives 99% when the
PPC
cradles?????

Any help would be appreciated.

Thanks,

..........................................................TJ
 

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

Similar Threads


Top