EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Sockets

Started by manaila September 2, 2011
Hi

I have an embedded linux system which I want to implement sockets
programming on it. I have used these examples:
               http://www.linuxhowtos.org/data/6/server.c
               http://www.linuxhowtos.org/data/6/client.c
I have integrated the client.c example on my embedded system and the
server.c example on the PC. So when I execute them, I get the "ERROR
connecting: Network is unreachable" error message from my embedded system.

What might be the cause of this; does the embedded linux have all the
libraries for networking.
	   
					
---------------------------------------		
Posted through http://www.EmbeddedRelated.com
In comp.arch.embedded,
manaila <chessmylitis@n_o_s_p_a_m.hotmail.com> wrote:
> Hi > > I have an embedded linux system which I want to implement sockets > programming on it. I have used these examples: > http://www.linuxhowtos.org/data/6/server.c > http://www.linuxhowtos.org/data/6/client.c > I have integrated the client.c example on my embedded system and the > server.c example on the PC. So when I execute them, I get the "ERROR > connecting: Network is unreachable" error message from my embedded system. > > What might be the cause of this; does the embedded linux have all the > libraries for networking.
Sounds like your network is not properly configured. Are PC and client on the same network and did you set up IP address and netmask? Try the commands "ifconfig -a" and "route -n" and post the output here. Also try pinging your PC from your embedded system and vice versa. -- Stef (remove caps, dashes and .invalid from e-mail address to reply by mail) Surprise due today. Also the rent.
In article <QaydnfIp9fGUF_3TnZ2dnUVZ_qOdnZ2d@giganews.com>, 
chessmylitis@n_o_s_p_a_m.hotmail.com says...
> > Hi > > I have an embedded linux system which I want to implement sockets > programming on it. I have used these examples: > http://www.linuxhowtos.org/data/6/server.c > http://www.linuxhowtos.org/data/6/client.c > I have integrated the client.c example on my embedded system and the > server.c example on the PC. So when I execute them, I get the "ERROR > connecting: Network is unreachable" error message from my embedded system. > > What might be the cause of this; does the embedded linux have all the > libraries for networking. > > > --------------------------------------- > Posted through http://www.EmbeddedRelated.com
You have actually checked one can Ping the other? Sounds more like basic network setup or firewall on PC, not letting you connect to that service. Without any other information, that is the nest anyone can give you. -- Paul Carpenter | paul@pcserviceselectronics.co.uk <http://www.pcserviceselectronics.co.uk/> PC Services <http://www.pcserviceselectronics.co.uk/fonts/> Timing Diagram Font <http://www.gnuh8.org.uk/> GNU H8 - compiler & Renesas H8/H8S/H8 Tiny <http://www.badweb.org.uk/> For those web sites you hate
>In article <QaydnfIp9fGUF_3TnZ2dnUVZ_qOdnZ2d@giganews.com>, >chessmylitis@n_o_s_p_a_m.hotmail.com says... >> >> Hi >> >> I have an embedded linux system which I want to implement sockets >> programming on it. I have used these examples: >> http://www.linuxhowtos.org/data/6/server.c >> http://www.linuxhowtos.org/data/6/client.c >> I have integrated the client.c example on my embedded system and the >> server.c example on the PC. So when I execute them, I get the "ERROR >> connecting: Network is unreachable" error message from my embedded
system.
>> >> What might be the cause of this; does the embedded linux have all the >> libraries for networking. >> >> >> --------------------------------------- >> Posted through http://www.EmbeddedRelated.com > >You have actually checked one can Ping the other? > >Sounds more like basic network setup or firewall on PC, not letting >you connect to that service. > >Without any other information, that is the nest anyone can give you. > >-- >Paul Carpenter | paul@pcserviceselectronics.co.uk ><http://www.pcserviceselectronics.co.uk/> PC Services ><http://www.pcserviceselectronics.co.uk/fonts/> Timing Diagram Font ><http://www.gnuh8.org.uk/> GNU H8 - compiler & Renesas H8/H8S/H8 Tiny ><http://www.badweb.org.uk/> For those web sites you hate >
The PC and the embedded system are on the same network. Network setup[i.e IP, subnet mask, gateway] has been done on both of them. This is what I get when I try to ping the embedded system: PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data. From 192.168.1.4 icmp_seq=1 Destination Host Unreachable But the PC can be pinged by other PCs. Because of limited memory on the embedded system there are only basic libraries on it: It has U-Boot, Linux Kernel image, Basic Linux file systems, Busyness, etc. I'm new to linux embedded systems, so I am not sure of which libraries/addons I have to include in my embedded system in order to allow pinging and having that example to work on it. Please help.. --------------------------------------- Posted through http://www.EmbeddedRelated.com
On Fri, 02 Sep 2011 05:04:52 -0500, manaila wrote:

> The PC and the embedded system are on the same network. > Network setup[i.e IP, subnet mask, gateway] has been done on both of them. > This is what I get when I try to ping the embedded system: > PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data. > From 192.168.1.4 icmp_seq=1 Destination Host Unreachable
Check your routing table ("route -n"). It should have an entry like: Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
On Sep 2, 4:28=A0pm, Paul <p...@pcserviceselectronics.co.uk> wrote:
> In article <QaydnfIp9fGUF_3TnZ2dnUVZ_qOdn...@giganews.com>, > chessmylitis@n_o_s_p_a_m.hotmail.com says... > > > > > > > > > > > > > Hi > > > I have an embedded linux system which I want to implement sockets > > programming on it. I have used these examples: > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://www.linuxhowtos.org/data/6/server=
.c
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://www.linuxhowtos.org/data/6/client=
.c
> > I have integrated the client.c example on my embedded system and the > > server.c example on the PC. So when I execute them, I get the "ERROR > > connecting: Network is unreachable" error message from my embedded syst=
em.
> > > What might be the cause of this; does the embedded linux have all the > > libraries for networking. > > > --------------------------------------- =A0 =A0 =A0 =A0 =A0 =A0 > > Posted throughhttp://www.EmbeddedRelated.com > > You have actually checked one can Ping the other? > > Sounds more like basic network setup or firewall on PC, not letting > you connect to that service. > > Without any other information, that is the nest anyone can give you. > > -- > Paul Carpenter =A0 =A0 =A0 =A0 =A0| p...@pcserviceselectronics.co.uk > <http://www.pcserviceselectronics.co.uk/> =A0 =A0PC Services > <http://www.pcserviceselectronics.co.uk/fonts/> Timing Diagram Font > <http://www.gnuh8.org.uk/> =A0GNU H8 - compiler & Renesas H8/H8S/H8 Tiny > <http://www.badweb.org.uk/> For those web sites you hate
Yes, Paul got to be correct. Unless you tell more, check the 'ping', ofcouse you can waste more time to do nmap , route etc. regards, ali
Hi Manaila,

On 9/2/2011 12:47 AM, manaila wrote:
> I have an embedded linux system which I want to implement sockets > programming on it. I have used these examples: > http://www.linuxhowtos.org/data/6/server.c > http://www.linuxhowtos.org/data/6/client.c > I have integrated the client.c example on my embedded system and the > server.c example on the PC. So when I execute them, I get the "ERROR > connecting: Network is unreachable" error message from my embedded system.
Have you assigned an IP address to your host? Netmask? Are you sure the host and PC are on the same physical and logical network segment? Is the interface *up*? Are you using names or IP's to specify your endpoints? I.e., do you have a resolver running? Have you correctly *specified* the endpoints (typographical errors, etc.)?
> What might be the cause of this; does the embedded linux have all the > libraries for networking.
"I designed a circuit to blink an LED. But, the LED isn't blinking..." (i.e., you haven't told us enough to do more than list a litany of *possible* problems -- "Is the LED wired into the circuit BACKWARDS?") You might try a Linux forum for more specific details (like, perhaps the vendor who provided you with your *hardware*?)
>On Fri, 02 Sep 2011 05:04:52 -0500, manaila wrote: > >> The PC and the embedded system are on the same network. >> Network setup[i.e IP, subnet mask, gateway] has been done on both of
them.
>> This is what I get when I try to ping the embedded system: >> PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data. >> From 192.168.1.4 icmp_seq=1 Destination Host Unreachable > >Check your routing table ("route -n"). It should have an entry like: > >Destination Gateway Genmask Flags Metric Ref Use
Iface
>192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0
eth0
> > >
My routing table was empty and I have configured it, and it now look like: Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 Pinging to and from my embedded system is now successful. But when doing "that" example, I get the following error: ERROR connecting: No route to host How can I fix this error? --------------------------------------- Posted through http://www.EmbeddedRelated.com
On Mon, 05 Sep 2011 08:43:52 -0500, manaila wrote:

> My routing table was empty and I have configured it, and it now look like:
You may also want an entry for 127.0.0.1/8.
> Pinging to and from my embedded system is now successful. > But when doing "that" example, I get the following error: > ERROR connecting: No route to host
"No route to host" (EHOSTUNREACH) can result from a variety of causes, including: + there is no routing table entry for the destination + the route has a gateway and there is no routing table entry for the gateway's address + the link-layer (e.g. ethernet) address for the next hop (destination or gateway) cannot be obtained (e.g. via ARP). + the packet elicits an ICMP "host unreachable" (type 3, code 1) response
> How can I fix this error?
Print the IP address of the target, to ensure that you're connecting to the right host. Check the contents of the ARP cache on each end. Beyond that, I can only suggest running tcpdump to observe the actual network traffic. This needs to be done on the system you're trying to monitor, or on a host which is connected to the one you're trying to monitor via a hub (a switch won't work unless it has a monitoring port).

The 2024 Embedded Online Conference