Hi, i have a simple question. i want to send a message from my netduino plus, to my pc. I want [color=rgb(0,0,0);font-family:arial, sans-serif;font-size:13px;font-weight:bold;] to establish my Nd+ as a master and my computer as a slave[/color]. Here is the code, the IP Address Pc is 192.168.1.100. have i an error, or is this possible?. Thanks
Code ND+:
Public
class Program
{
Public
static void Main()
{
OutputPort led = new OutputPort(Pins.ONBOARD_LED,
false);
Socket sck = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
IPEndPoint localEndPoint = new
IPEndPoint(IPAddress.Parse("192.168.1.100"),44818); //Direccion IP del PC
sck.Connect(localEndPoint);
try
{
sck.Connect(localEndPoint);
string Sender_Context = "Conectar";
byte[] data = Encoding.UTF8.GetBytes(Sender_Context);
sck.Send(data);
Debug.Print("Sender_Context enviado");
sck.Close();
}
catch
{
Debug.Print("imposible conectar con el PC rn");
}
}
}
Code PC:
Class Program
{
Static
void Main(string[] args)
{
Socket sck = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
IPEndPoint localEndPoint = new
IPEndPoint(IPAddress.Any,
44818);
sck.Bind(localEndPoint);
sck.Listen(100);
Socket clientSocket;
while
(true)
{
clientSocket = sck.Accept();
Byte[] buffer = newByte[100];
clientSocket.Receive(buffer);
string
request = newstring(Encoding.UTF8.GetChars(buffer));
//////////////////////////////////////
Console.Write(request);
}
}
}