Ethernet Shield to PC and connect to local server

Hello,

I have a server generating random data on my PC. I want to use an Arduino with an Ethernet shield connected directly to the PC via Ethernet and access the server to receive the data.

I tested the server and am able to recieved data using a virtual client in C#. I can successfully access the data using IPEndPoint Class. Now I want to replicate this with Arduino + Ethernet Shield.

My knowledge in TCP/IP networking is very little. How do I configure the Ethernet shield as a client and connect it directly to the PC (not via router) and the server.

Regards,

dgelman:
Hello,

I have a server generating random data on my PC. I want to use an Arduino with an Ethernet shield connected directly to the PC via Ethernet and access the server to receive the data.

That's not how LAN/Ethernet works.

Typically, the network is established by a "router".

And each device has to be connected to the router".

Either directly, or via a device named "switch.

Correct network connections would be

  • connect all devices to the router
  • connect a switch to the router, then connect all devices to the switch.

Wrong network setup would be:

  • connect PC to the router (until here it is OK)
    . then connect different network devices to the PC (here it becomes WRONG)

Using a router is the best way of achieving this, especially if you are not a network specialist.

However, if, during the time your PC is connected to the Arduino, you don't need to connect it [the PC] to another network, internet etc., you may just get away with giving both the PC and the Arduino a static IP address in the same network eg: PC- 192.168.1.1 Arduino 192.168.1.2 using the subnet mask 255.255.255.0 . Sometimes you may need a special crossover cable to connect two hosts together ( depending on MDI-X support on the Ethernet adapters).

jurs:
That's not how LAN/Ethernet works.

Typically, the network is established by a "router".

And each device has to be connected to the router".

Either directly, or via a device named "switch.

Correct network connections would be

  • connect all devices to the router
  • connect a switch to the router, then connect all devices to the switch.

Wrong network setup would be:

  • connect PC to the router (until here it is OK)
    . then connect different network devices to the PC (here it becomes WRONG)

I want to add onto my original post and perhaps that will help.

I have an identical system setup where a sever (generating data) is on a CPU. And I am able to access the data using a laptop via an Ethernet cable and a C# program that access the same IP.

I now want to be able to access the same server using an Arduino + Ethernet shield, and not a laptop. I am restricted in connecting the CPU running the server onto a router.

6v6gt:
Using a router is the best way of achieving this, especially if you are not a network specialist.

However, if, during the time your PC is connected to the Arduino, you don't need to connect it [the PC] to another network, internet etc., you may just get away with giving both the PC and the Arduino a static IP address in the same network eg: PC- 192.168.1.1 Arduino 192.168.1.2 using the subnet mask 255.255.255.0 . Sometimes you may need a special crossover cable to connect two hosts together ( depending on MDI-X support on the Ethernet adapters).

I believe this is what I need to do. I picked up a cross-over ethernet adapter this morning. Can you provide some sample code on what do to? I do not know how to use the Ethernet library on Arduino.

There are stacks of example around. You're wanting to create an ethernet client.
You can start here and look in particular at the connect() method of the EthernetClient class