Sockets problems 
Author Message
 Sockets problems

Hello,
I'm new to Win Ce, so sorry for dumb questions. I code using EVC and
I'm having problems dealing with sockets.

1)Why doesn't Receive() work after writing to the socket and I have to
shutdown writing in socket. And how to write to it again(without
recconect)? This problem occurs using both WinSock api and CCeSocket.

2)I need to connect using fixed timeout, how can i set timeout? SetOpt
does not support changing timeout in Win CE.

3)How can I deal with socket functions without blocking thread. I
tried IOCtl(), but after i enabled nonblocking mode of the socket
function Connect() hangs.

4)Where can i find examples of woking with sockets?

Very thank you for any help!



Wed, 19 Oct 2005 12:50:22 GMT  
 Sockets problems
If you provide some details about your application and your environment,
that will help. What version of CE? What kind of CE device? What is running
on the CE device - the sending part or the receiving part or both? What type
of network interface - NIC, modem? What type of socket - SOCK_DGRAM or
SOCK_STREAM? See inline for comments...

--
Srivatsa Srinivasan
Windows CE Networking
ssriniva AT microsoft DOT com
_____________________________________________________________
This posting is provided "AS IS" with no warranties, and confers no rights.
_____________________________________________________________


Quote:
> Hello,
> I'm new to Win Ce, so sorry for dumb questions. I code using EVC and
> I'm having problems dealing with sockets.

> 1)Why doesn't Receive() work after writing to the socket and I have to
> shutdown writing in socket. And how to write to it again(without
> recconect)? This problem occurs using both WinSock api and CCeSocket.

Assuming this is a SOCK_STREAM socket and that the connection succeeded, do
you mean that the recv blocks in the receiving part even though send
returned successfully in the sending part? And that only upon calling
shutdown on the sending part does recv return with the data? Or is the recv
side socket non-blocking (then you would have to handle this in a special
way - see the MSDN docs)? No, you cannot write to a socket that has been
shutdown (with either SD_BOTH or SD_SEND as the "how" parameter) unless you
used "how" parameter to be SD_RECEIVE.

Provide us a network trace if you can and also a brief desricption of the
data flow you expect to happen

Quote:

> 2)I need to connect using fixed timeout, how can i set timeout? SetOpt
> does not support changing timeout in Win CE.

You can use a non-blocking socket and the select statement to achieve this
on CE. When you call connect, it immediately returns with WSAEWOULDBLOCK.
Then you can call select on the socket with whatever timeout you want passed
in to select. When the connection is made, the read descriptor will be set
(or the except descriptor if there was a error) for your socket OR the
select will timeout at the timeout you have set. See the CE MSDN winsock
connect docs for all the details

Quote:

> 3)How can I deal with socket functions without blocking thread. I
> tried IOCtl(), but after i enabled nonblocking mode of the socket
> function Connect() hangs.

Did the ioctl succeed? If you can provide the source and say which version
of CE you are using, perhaps we can investigate more?

Quote:

> 4)Where can i find examples of woking with sockets?

MSDN has lots of samples (including a simple winsock client and server) -
even though they are for the desktop, they should be applicable to CE as
well.
Quote:

> Very thank you for any help!



Thu, 20 Oct 2005 02:39:35 GMT  
 Sockets problems
3) Don't.  Use separate threads to communicate over sockets, so that
communication delays don't show up in your user interface.  If, for some
strange reason, you must have only a single thread, use select() to check
the readiness of a socket to perform the operation you're about to do before
actually doing it.  select() takes a time-out value...

4) Examples of what sort?  I've posted small sections of code for doing
various things before...

Paul T.


Quote:
> Hello,
> I'm new to Win Ce, so sorry for dumb questions. I code using EVC and
> I'm having problems dealing with sockets.

> 1)Why doesn't Receive() work after writing to the socket and I have to
> shutdown writing in socket. And how to write to it again(without
> recconect)? This problem occurs using both WinSock api and CCeSocket.

> 2)I need to connect using fixed timeout, how can i set timeout? SetOpt
> does not support changing timeout in Win CE.

> 3)How can I deal with socket functions without blocking thread. I
> tried IOCtl(), but after i enabled nonblocking mode of the socket
> function Connect() hangs.

> 4)Where can i find examples of woking with sockets?

> Very thank you for any help!



Sat, 22 Oct 2005 03:58:06 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Async Socket Problem

2. Socket problem + multiple threads

3. socket problem

4. socket problem

5. Socket Problem

6. raw-socket problem

7. Windows socket problem (please help)

8. Sockets problem

9. Creating Socket problem

10. socket problem

11. socket problems

12. Sockets Problem

 

 
Powered by phpBB® Forum Software