tcp

Simple One Thread Socket - TCP Server

笑着哭i 提交于 2020-12-04 05:16:50
问题 First, I don't know if Stackoverflow is the best site to post this kind of message, but I don't know another sites like this. In oder to understand properly tcp programmation in C#, I decided to do all possible ways from scratch. Here is what I want to know (not in the right order: - Simple One Thread Socket Server (this article) - Simple Multiple Threads Socket Server (I don't know how, cause threads are complicated) - Simple Thread Socket Server (put the client management in another thread)

How would I constant listen on a port with a GUI?

纵饮孤独 提交于 2020-12-03 23:47:33
问题 I am trying to learn TCP server/client interaction. I want to know how I would listen to a port all the time with GUI. Currently I am using this code: private void Form1_Load(object sender, EventArgs e) { CreateServer(); } void CreateServer() { TcpListener tcp = new TcpListener(25565); tcp.Start(); Thread t = new Thread(() => { while (true) { var tcpClient = tcp.AcceptTcpClient(); ThreadPool.QueueUserWorkItem((_) => { Socket s = tcp.AcceptSocket(); console.Invoke((MethodInvoker)delegate {

C++ How can I send an object via socket?

眉间皱痕 提交于 2020-11-26 19:41:12
问题 I have a question for you. I have this class: ` #define DIMBLOCK 128 #ifndef _BLOCCO_ #define _BLOCCO_ class blocco { public: int ID; char* data; blocco(int id); }; #endif blocco::blocco(int id) { ID = id; data = new char[DIMBLOCK]; } ` and the application has a client and a server. In the main of my server I instantiate an object of this class in this way: blocco a(1); After that I open a connection between the client and the server using sockets. The question is: how can I send this object

C++ How can I send an object via socket?

我是研究僧i 提交于 2020-11-26 19:33:58
问题 I have a question for you. I have this class: ` #define DIMBLOCK 128 #ifndef _BLOCCO_ #define _BLOCCO_ class blocco { public: int ID; char* data; blocco(int id); }; #endif blocco::blocco(int id) { ID = id; data = new char[DIMBLOCK]; } ` and the application has a client and a server. In the main of my server I instantiate an object of this class in this way: blocco a(1); After that I open a connection between the client and the server using sockets. The question is: how can I send this object

C++ How can I send an object via socket?

丶灬走出姿态 提交于 2020-11-26 19:31:10
问题 I have a question for you. I have this class: ` #define DIMBLOCK 128 #ifndef _BLOCCO_ #define _BLOCCO_ class blocco { public: int ID; char* data; blocco(int id); }; #endif blocco::blocco(int id) { ID = id; data = new char[DIMBLOCK]; } ` and the application has a client and a server. In the main of my server I instantiate an object of this class in this way: blocco a(1); After that I open a connection between the client and the server using sockets. The question is: how can I send this object