I am using x86 CEPC CE 4.2 platform.
This platform has a modem.
I dial a RAS entry and connect to the Internet. I create a server socket
through calls to socket()...bind()...listen() and I am able to receive
connections on the socket to the IP that the modem receives.
The problem occurs when I add a LAN support to my platform. When I have LAN
support, I automatically receive an IP from the DHCP server. Now, my device
has two IP: one from the LAN and one from the modem I used to dial to the
Internet.
But when I am connected to the LAN, I am no longer able to receive
connection on the server sockets() using the IP that the modem receives.

Is this the expected behaviour? What shold I do in order to receive
connections in cases that I also have an IP from the LAN?

Thanks.
Offir.

RE: Listen socket problem by coreyb

coreyb
Mon May 03 20:47:39 CDT 2004

What address are you binding to? INADDR_ANY?


Re: Listen socket problem by Offir

Offir
Tue May 04 02:13:29 CDT 2004

Yes:

struct sockaddr_in sa ;
ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

if (ListenSocket == INVALID_SOCKET)
{
... handle errror
}

sa.sin_family = AF_INET ;
sa.sin_port = htons ((short)
Configuration.communication.LISTEN_PORT);
sa.sin_addr.S_un.S_addr = INADDR_ANY;

iError = bind(ListenSocket, (LPSOCKADDR) &sa, sizeof(sa));
if (iError != 0)
{
...handle error
}

iError = listen(ListenSocket, 1);
if (iError != 0)
{
...handle error
}



Re: Listen socket problem by Paul

Paul
Tue May 04 13:18:56 CDT 2004

If you want to bind to a specific IP address (so that the socket is
associated with either the phone line or the wired network), you can do that
by putting the IP in the S_addr entry there in your code.

In other words, yes, it is the expected behavior.

Paul T.

"Offir Bakshitz" <bakshitz@email.com> wrote in message
news:%23aobXdaMEHA.1388@TK2MSFTNGP09.phx.gbl...
> Yes:
>
> struct sockaddr_in sa ;
> ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
>
> if (ListenSocket == INVALID_SOCKET)
> {
> ... handle errror
> }
>
> sa.sin_family = AF_INET ;
> sa.sin_port = htons ((short)
> Configuration.communication.LISTEN_PORT);
> sa.sin_addr.S_un.S_addr = INADDR_ANY;
>
> iError = bind(ListenSocket, (LPSOCKADDR) &sa, sizeof(sa));
> if (iError != 0)
> {
> ...handle error
> }
>
> iError = listen(ListenSocket, 1);
> if (iError != 0)
> {
> ...handle error
> }
>
>