Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

TCP/IP Client and Server basic using and references

$
0
0

I have installed TCP/IP from VS15 NuGet Packeges into my project and in References it is as SimpleTCP, I've rebuild project, but for SimpleTcpClient client; it says:

Suppression State Error CS0246 The type or namespace name'SimpleTcpServer' could not be found (are you missing a using directive or an assembly reference?)

not sure what can be cause of that, maybe I missed some references or even using.

Client:

using System;using System.Text;using System.Windows.Forms;namespace Client{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        SimpleTcpClient client;        private void button1_Click(object sender, EventArgs e)        {            button1.Enabled = false;        }        private void button2_Click(object sender, EventArgs e)        {            client.WriteLineAndGetReplay(txtMessage.Text, TimeSpan.FromSeconds(5));        }        private void Form1_Load(object sender, EventArgs e)        {            client = new SimpleTcpClient();            client.StringEncoder = Encoding.UTF8;            client.DataRecevived += Client_DataReceived;        }        private void Client_DataReceived(object sender, SimpleTCP.Message e)        {            textBox1.Invoke((MethodInvoker)delegate ()            {                textBox1.Text += e.MessageString;            });        }    }}

Server:

using System;using System.Text;using System.Windows.Forms;namespace Server{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        SimpleTcpServer server;        private void Form1_Load(object sender, EventArgs e)        {            server = new SimpleTcpServer();            server.Delimeter = 0x13;            server.StringEncoder = Encoding.UTF8;            server.DataReceived += Server_DataReceived;        }        private void Server_DataReceived(object sender, SimpleTCP.Message e)        {            txtStatus.Invoke((MethodInvoker)delegate ()            {                txtStatus.Text += e.MessageString;                e.ReplyLine(string.Format("You said: {0}", e.MessageString));            });                  }        private void btnStart_Click(object sender, EventArgs e)        {            txtStatus.Text += "Server starting...";            System.Net.IPAddress ip = new System.Net.IPAddress(long.Parse(txtHost.Text));            server.Start(ip, Convert.ToInt32(txtPort.Text));        }        private void btnStop_Click(object sender, EventArgs e)        {            if (server.IsStarted)            {                server.Stop();            }        }    }}

Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>