I am d开发者_Go百科eveloping a web for my project. I am new to Asp.net and to this forum. my project is control a led from website.
I am using network module to connect my microcontroler with web server. what i want to do is send variable from ASP.net to network module IP address.
I am very thanks to everyone who can help me here is ASP code (page.aspx.cs).
public partial class VirtualRemote : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
// when this button is click i want to send a variable example "A"
to network module IP example 192.168.1.2. so network module can pass the
variable to microC , i already have microC program to receive from network module
}
}
Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
clientSocket.Connect(new IPEndPoint(IPAddress.Parse("192.168.1.2"), PORT_NUMBER));
// Send the file name.
var A = "TEST STRING";
clientSocket.Send(Encoding.UTF8.GetBytes(A));
More about Socket
class
精彩评论