So what would you recommend as an alternative.
I made some changes,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Sockets;
using System.Threading;
using System.Net;
namespace DrawDumpSyringe
{
public partial class Form1 : Form
{
int i;
TcpClient client; // Creates a TCP Client
NetworkStream stream; //Creats a NetworkStream (used for sending and receiving data)
byte[] buffer = new byte[1024]; // creates a new byte with length 1024
public Form1()
{
InitializeComponent();
}
private void btn_connect_Click(object sender, EventArgs e)
{
try
{
client = new TcpClient(); //Trys to Connect
client.Connect(iptextBox.Text, 80);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message); // Error handler :D
}
}
private void btn_Draw_Click(object sender, EventArgs e)
{
if (client.Connected) // if the client is connected
{
buffer[0] = 43;
stream.Write(buffer, 0, buffer.Length);
}
}
private void btn_Eject_Click(object sender, EventArgs e)
{
if (client.Connected) // if the client is connected
{
buffer[0] = 44;
stream.Write(buffer, 0, buffer.Length);
}
}
}
}
Not sure if they are correct, honestly it does not seem that they are and it resembles a Serial port too much for me.
No comments:
Post a Comment