Re: connect() always returns true (0)



Probably, it should fail, but there are things that could be wrong that
would just generate unspecified behavior, possibly including the behavior
you're seeing. Check for a valid Ethernet address...

Paul T.

<csmith1a@xxxxxxxxx> wrote in message
news:d3900dc1-5eb2-4316-b2cd-3b432b821007@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Aug 19, 4:49 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
no instrument no spam DOT com> wrote:
Oh, and make sure that the device has a valid Ethernet address. Who knows
what would happen if its enet address was ff:ff:ff:ff:ff:ff or something
like that.

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT



com> wrote in messagenews:eJs0kSkAJHA.1748@xxxxxxxxxxxxxxxxxxxxxxx
You might try it quickly without binding the socket, since you don't
have
to bind an outgoing socket anyway. I'm just trying to eliminate possible
causes. It's worth double-checking that you are creating a stream, not a
datagram socket, too, although this is obviously unlikely to be the
cause.

Give us the IP of the device, the subnet mask of the device and PC, and
the gateway addresses of each, along with the IP that you're trying to
connect to.

I've tried to duplicate this on my CE5 device and nothing I do will
cause
it to return 0 unless it's actually connected. I've tried non-blocking,
not initializing WinSock, etc. I'm not using a simple cross-over cable,
so that might be a related factor. If you have a hub or switch, put it
in
the middle.

Paul T.

<csmit...@xxxxxxxxx> wrote in message
news:5371c054-a307-4c9a-91ce-75f197964efb@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Aug 19, 4:06 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
no instrument no spam DOT com> wrote:
What other calls have you made with that socket? Any setsockopt() or
ioctlsocket() calls? That *looks* to me like you've set up the socket
as
non-blocking, but are trying to treat it as a blocking socket (and
expecting
the connect operation to be complete when connect returns). I would
expect
that to cause WSAEWOULDBLOCK to be set, but maybe not.

The socket is bound to a particular network adapter (you called bind()
for
it)? Or not? If so, what sort of adapter is it (Ethernet, WiFi, etc.)?
Why are you expecting the connection to fail? Time-out? Actively
refused
by host? No route?

Finally, how about WHAT VERSION OF CE? And WHAT HARDWARE?

Paul T.

<csmit...@xxxxxxxxx> wrote in message

news:0937f3c3-125b-4230-bb26-268ca7da95d5@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I am converting a Win32 app to WinCe and one of the calls from the
Win32 app is a connect() call relating to sockets. When I put in a
boggas ip address in the struct sockaddr the connect() call will fail
on the Win32 side with a -1 while on the WinCE side it will always
return 0, indicating success. The socket call I am using is:
socket( AF_INET, SOCK_STREAM, 0 ).

I need to know a way to fall out ,in WinCe, when the ip address is
bogas, as in the Win32 app. Any ideas?

Thanks- Hide quoted text -

- Show quoted text -

1.) These are the two call using the socket (fd) before the connect()
call:
bind(fd, (PSOCKADDR )&pTBlk->)m_Cmd.m_LocalAddress, sizeof()&pTBlk-
m_Cmd.m_LocalAddress)

getsockopt(pTBlk->m_Socket_fd, IPPROTO_TCP, TCP_NODELAY,
(PCHAR )&pTBlk->m_Cmd.m_nSockOptNoDelay, &optlen )

2.) "Why are you expecting the connection to fail? "
Because the ip address is not real and it fails on the connect() call
in the win32 version.

3.) Finally, how about WHAT VERSION OF CE? And WHAT HARDWARE?
a. CE 5.0
b. CE development system(board) hooked to my PC via a ethernet
using a cross over cable.

I really appreciate you time.- Hide quoted text -

- Show quoted text -

Again I really appreciate you taking the time to try it on your
device. I must be doing something fundamentally wrong here but I am
just missing it.

I removed the bind call, still the same.

As for my test enviroment I have tried it with the no connection to
the ethernet at all, no cable even plugged in and I am still returning
a 0 on connect();

I am using bogus ip addresses just to test it, like 126.0.56.123 with
Subnet 255.0.0.0 and leaving Gateway empty, on the device as a static
address and using 124.0.12.105:5001 as the ip I am trying to connect
to.

Should connect not fail if all the ip addresses are fake and the
ethernet cable is not even plugged in?


.



Relevant Pages

  • Re: connect() always returns true (0)
    ... datagram socket, too, although this is obviously unlikely to be the cause. ... Why are you expecting the connection to fail? ... Win32 app is a connectcall relating to sockets. ... CE development systemhooked to my PC via a ethernet ...
    (microsoft.public.windowsce.embedded)
  • Re: connect() always returns true (0)
    ... and make sure that the device has a valid Ethernet address. ... datagram socket, too, although this is obviously unlikely to be the cause. ... Why are you expecting the connection to fail? ... Win32 app is a connectcall relating to sockets. ...
    (microsoft.public.windowsce.embedded)
  • Re: connect() always returns true (0)
    ... but are trying to treat it as a blocking socket (and expecting ... Why are you expecting the connection to fail? ... Win32 app is a connectcall relating to sockets. ...
    (microsoft.public.windowsce.embedded)
  • Re: connect() always returns true (0)
    ... You might try it quickly without binding the socket, ... bind an outgoing socket anyway. ... Why are you expecting the connection to fail? ... Win32 app is a connectcall relating to sockets. ...
    (microsoft.public.windowsce.embedded)
  • Re: A problem of UDP
    ... Probably an exceptionally poor decision. ... UDP is ill-suited for this purpose. ... Here is my code to start a socket: ... setsockopt, "Fail to enable broadcasting.", ...
    (microsoft.public.vc.mfc)

Loading