Sockets

Hi

I have an embedded linux system which I want to implement sockets programming on it. I have used these examples:

formatting link
formatting link
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

formatting link

Reply to
manaila
Loading thread data ...

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.
Reply to
Stef

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
    PC Services
 Timing Diagram Font
  GNU H8 - compiler & Renesas H8/H8S/H8 Tiny
 For those web sites you hate
Reply to
Paul

system.

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

formatting link

Reply to
manaila

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
Reply to
Nobody

.c

.c

em.

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

Reply to
Ali

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.)?

"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*?)
Reply to
Don Y

them.

Iface

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

formatting link

Reply to
manaila

You may also want an entry for 127.0.0.1/8.

"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

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).

Reply to
Nobody

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.