Can someone give me some guidence as to how to set up a simple text based Ethernet server that will respond to to character commands, much like simple RS-232.
I've looked at all of the ethernet samples with Arduino 1.0 software and was able to easily get the Chat Server up and running with Windows Command Prompt Ping command, so I know the hardwware is working. I'm having difficulty getting a response when I try to communicate with a Windows Application that I wrote.
This is my Visual C++ socket client connection code, which works with 3rd part hardware I use. I generally don't have to designate a gateway:
int SocketClass::Init(String^ hostAddress, int portNumber, int timeOut)
{
DWORD startTicks = GetTickCount();
DWORD currentTicks;
DWORD elapsedTicks;
int bytesSent,rcv;
if(m_socket!=nullptr)
delete m_socket;
if(m_endPoint!=nullptr)
delete m_endPoint;
m_endPoint = gcnew IPEndPoint(IPAddress::Parse(hostAddress), portNumber);
m_socket = gcnew Socket(AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp);
m_socket->SendTimeout = 1000;
m_socket->ReceiveTimeout = 1000;
m_socket->Blocking = false;
m_connected = -1;
try {
m_socket->BeginConnect( m_endPoint, gcnew AsyncCallback(this, &SocketClass::ConnectCallback), m_socket );
}
catch (Exception^ e) {
System::Windows::Forms::MessageBox::Show("BeginConnect Exception Thrown");
}
elapsedTicks = 0;
currentTicks = GetTickCount();
do{
currentTicks = GetTickCount();
elapsedTicks = currentTicks - startTicks;
if(m_connected == 1)
{
return 0;
}
Sleep(1);
}while (elapsedTicks<timeOut);
m_connected = 0;
//delete m_socket;
return -1;
}
I don't need internet access, I'm just communicating with the host Windows application over a switch.
Any guidence as to how to set up a simple terminal-style server would be appreciated.
Hardware: Nano 3.0/328p and Wiznet WIZ811MJ
Thanks
Rennie