EmbeddedRelated.com
Forums

TCP/IP connection problem - assigned IP, simple Java GUI

Started by rabbit_killer79 May 29, 2006
Hi,

I've got a problem connecting to a RCM3700 which is assigned an IP
from the network (so I know the IP) from a simple Java GUI. I've tried
a lot of different combinations, followed advice from other posts on
this group, and i've gotten nowhere. If someone could go through the
best way to get an assigned IP from a server, and then connect to it
from anywhere (knowing the IP), sending the rabbit a string command to
get a string response. A simple too-the-point sample would be cool, if
not a problem. I'm unfamiliar with this type of communication, so any
help would be appreciated.

Thanks,
Phil

Phil,

Some of what you have said isn't to clear.
Exactly what do you mean by
"assigned an IP from the network (so I know the IP)"

I assume you mean you are using DHCP and allowing a router or
firewall to assign you an IP. How do you know the IP you are being
assigned?

As for "best way to get an assigned IP from a server" there is only
ONE way to do this, DHCP. If you use the IP configuration that is
DHCP you will get assigned an IP, the trick is to know what IP you
were given. In debug mode you can print the IP address that the
device was give after the the ethernet interface is up or if your
device has a display you can show it. Some firewall routers have a
maintaince page that will display all the IP address's it has
currently given out by MAC address and sometimes by machine name.

FWIW in general it's not a very good idea to have servers get a
dynamic IP since all you clients will have to some how find this
address out.

If you are behind a firewall or router there are several things you
can do, depending on the router/firewall. Some firewalls (like the
cheap linsys one) assign IP address fro 192.168.1.100 and up, so you
can use a fixed IP in the 192.168.1.1 - 99 range and everything will
work just fine (other firewalls do similar things but use a
different part of the 192.168.x.x range.)

Some routers/firewalls will have configuration options that will let
you essentially assign a IP to a certian MAC address.

Note that none of these options is worth anythng in a real product
since it places to big a burden on the end user to figure out what
address the rabbit was given.

You haven't mentioned if you can "ping" this device to prove that
you really know the IP address, if you can then the bug is not in
the DCHP, if you can't you don't know it's address.

Dynamic C provides several "simple and to the point" examples.

BTW if you aren't very familure with TCP/IP you are really swimming
up stream, there are MANY pitfalls here.
--.- Dave

--- In r..., "rabbit_killer79"
wrote:
>
> Hi,
>
> I've got a problem connecting to a RCM3700 which is
assigned an IP
> from the network (so I know the IP) from a simple Java GUI. I've
tried
> a lot of different combinations, followed advice from other posts
on
> this group, and i've gotten nowhere. If someone could go through
the
> best way to get an assigned IP from a server, and then connect to
it
> from anywhere (knowing the IP), sending the rabbit a string
command to
> get a string response. A simple too-the-point sample would be
cool, if
> not a problem. I'm unfamiliar with this type of communication, so
any
> help would be appreciated.
>
> Thanks,
> Phil
>





Hi Dave,

Sorry about the clairity of my last post - it was late into a long
day for me, and I thought less detail would be better for some
reason.

Anyway, I'm using DHCP, I want a router, etc. to assign IP, and for
now I am getting the IP from the Debug window, i'll worry about
getting the IP a bit later.

There are some straight forward examples in Dynamic C - getting the
IP using DHCP was fairly easy. the problem i'm having is connecting
to it afterwords. I can ping it easily enough from a PC, but trying
to connect using a simple socket client in Java is not working - the
rabbit is not seeing the connection at all. I believe the problem is
on that end - could you give me some advice as to what to run after
I've gotten my IP - UDP, TCP/IP - and how to implement that. I have
had a simple direct PC to rabbit connection working, see basic setup
below

#define TCPCONFIG 0
#define USE_ETHERNET 1

...
if(tcp_tick(&socket)==0 && conn_state!=CONNECTION_INIT)
{
sock_close(&socket);
conn_state=CONNECTION_CLOSED;
}
switch(conn_state)
{
/******** Initialize Connection ********/
case CONNECTION_INIT:
tcp_listen(&socket,MY_PORT,0,0,NULL,0);
conn_state=CONNECTION_LISTEN;
break;
/******** Listen For Connection ********/
case CONNECTION_LISTEN:
if(sock_established(&socket))
{
conn_state=CONNECTION_OPEN;
timeout=SEC_TIMER+TIMEOUT;
}
break;
/******* Process Input Commands ********/
case CONNECTION_OPEN:
if((long) (SEC_TIMER-timeout) >= 0)
{
sock_close(&socket);
conn_state=CONNECTION_CLOSED;
break;
}
bytes_read = 0;
if(sock_bytesready(&socket) != -1)
{ //Read in commands if any are ready
bytes_read = sock_fastread(&socket, tcp_buffer,
MAX_BUFLEN);
}
if(bytes_read < 0)
{
sock_close(&socket);
conn_state=CONNECTION_CLOSED;
break;
}
if(bytes_read > 0)
{
receive_data(tcp_buffer, bytes_read);
}
break;
/********** Close Connection ***********/
case CONNECTION_CLOSED:
conn_state=CONNECTION_INIT;
break;
/*************** Default ***************/
default:
conn_state = CONNECTION_OPEN;
break;
}

I just want to run a similar type setup with DHCP... cannot get it
too work, what am I missing?

Phil

--- In r..., "Dave August" wrote:
>
> Phil,
>
> Some of what you have said isn't to clear.
> Exactly what do you mean by
> "assigned an IP from the network (so I know the IP)"
>
> I assume you mean you are using DHCP and allowing a router or
> firewall to assign you an IP. How do you know the IP you are being
> assigned?
>
> As for "best way to get an assigned IP from a server" there is
only
> ONE way to do this, DHCP. If you use the IP configuration that is
> DHCP you will get assigned an IP, the trick is to know what IP you
> were given. In debug mode you can print the IP address that the
> device was give after the the ethernet interface is up or if your
> device has a display you can show it. Some firewall routers have a
> maintaince page that will display all the IP address's it has
> currently given out by MAC address and sometimes by machine name.
>
> FWIW in general it's not a very good idea to have servers get a
> dynamic IP since all you clients will have to some how find this
> address out.
>
> If you are behind a firewall or router there are several things
you
> can do, depending on the router/firewall. Some firewalls (like
the
> cheap linsys one) assign IP address fro 192.168.1.100 and up, so
you
> can use a fixed IP in the 192.168.1.1 - 99 range and everything
will
> work just fine (other firewalls do similar things but use a
> different part of the 192.168.x.x range.)
>
> Some routers/firewalls will have configuration options that will
let
> you essentially assign a IP to a certian MAC address.
>
> Note that none of these options is worth anythng in a real product
> since it places to big a burden on the end user to figure out what
> address the rabbit was given.
>
> You haven't mentioned if you can "ping" this device to prove that
> you really know the IP address, if you can then the bug is not in
> the DCHP, if you can't you don't know it's address.
>
> Dynamic C provides several "simple and to the point" examples.
>
> BTW if you aren't very familure with TCP/IP you are really
swimming
> up stream, there are MANY pitfalls here.
>
>
> --.- Dave
>
>
>
>
> --- In r..., "rabbit_killer79"
> wrote:
> >
> > Hi,
> >
> > I've got a problem connecting to a RCM3700 which is
> assigned an IP
> > from the network (so I know the IP) from a simple Java GUI. I've
> tried
> > a lot of different combinations, followed advice from other
posts
> on
> > this group, and i've gotten nowhere. If someone could go through
> the
> > best way to get an assigned IP from a server, and then connect
to
> it
> > from anywhere (knowing the IP), sending the rabbit a string
> command to
> > get a string response. A simple too-the-point sample would be
> cool, if
> > not a problem. I'm unfamiliar with this type of communication,
so
> any
> > help would be appreciated.
> >
> > Thanks,
> > Phil
>





Phil,

Less information is NEVER a good thing.

By virtue of being able to ping it, you know the stack is up and all
is kosher there.

What is it exactly you are trying to do?

Are you trying to run your own protocol on a private port?

If not, if you are trying to use http: and port 80 why don't you use
the http lib, why are you trying to run the socket you self with
tcp_tick();

The FIRST thing I'd do is drag in the http lib, stick up a simple
web page an load it, forget yer Java GUI. (BTW for all we know yer
Jiva is screwed up)

Once that works you can get as fancy as you want, run private
protocols or what ever.

FWIW most things on the rabbit can be accomplished with http and
some clever CGI_BIN, no real need to go to a private protocol.

Dave

--- In r..., "rabbit_killer79"
wrote:
>
> Hi Dave,
>
> Sorry about the clairity of my last post - it was late into a long
> day for me, and I thought less detail would be better for some
> reason.
>
> Anyway, I'm using DHCP, I want a router, etc. to assign IP, and
for
> now I am getting the IP from the Debug window, i'll worry about
> getting the IP a bit later.
>
> There are some straight forward examples in Dynamic C - getting
the
> IP using DHCP was fairly easy. the problem i'm having is
connecting
> to it afterwords. I can ping it easily enough from a PC, but
trying
> to connect using a simple socket client in Java is not working -
the
> rabbit is not seeing the connection at all. I believe the problem
is
> on that end - could you give me some advice as to what to run
after
> I've gotten my IP - UDP, TCP/IP - and how to implement that. I
have
> had a simple direct PC to rabbit connection working, see basic
setup
> below
>