multi tcp clients
-
Hello everyone, I try to connect a pc to some esp32 arudino boards using tcp sockets the idea is that on the each esp board I open a server that accapt the pc( client ) request and also a client that is used to do all data traffic between the pc and esp the pc and the board use the some router as AP i wrote some thing like that using Jyhton Now i want to do the some for other project but on the PC I run a VS2022 C# program that connect to the esp boards but i don't know how to do it . Can someone show me the road ( an example will be great ) Regards Doron
-
Hello everyone, I try to connect a pc to some esp32 arudino boards using tcp sockets the idea is that on the each esp board I open a server that accapt the pc( client ) request and also a client that is used to do all data traffic between the pc and esp the pc and the board use the some router as AP i wrote some thing like that using Jyhton Now i want to do the some for other project but on the PC I run a VS2022 C# program that connect to the esp boards but i don't know how to do it . Can someone show me the road ( an example will be great ) Regards Doron
You are going to have to give us a lot more detail than that - we have no idea what you have tired, where you are stuck, or what help you might need - if you have a working example, most developers should be able to alter it to fit the new circumstances, so we are at a loss to know what you expect from us that will help you get there.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
You are going to have to give us a lot more detail than that - we have no idea what you have tired, where you are stuck, or what help you might need - if you have a working example, most developers should be able to alter it to fit the new circumstances, so we are at a loss to know what you expect from us that will help you get there.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
Hello everyone, I try to connect a pc to some esp32 arudino boards using tcp sockets the idea is that on the each esp board I open a server that accapt the pc( client ) request and also a client that is used to do all data traffic between the pc and esp the pc and the board use the some router as AP i wrote some thing like that using Jyhton Now i want to do the some for other project but on the PC I run a VS2022 C# program that connect to the esp boards but i don't know how to do it . Can someone show me the road ( an example will be great ) Regards Doron
Doesn't matter how you 'think' about the design the following is true. For TCP sockets there is always a 'server' and a 'client'. The 'server' creates a listener port and waits for a connection. The 'client' opens a socket to the server. So the client is the one that initiates the connection. After a connection is created either side can send and receive requests. Although often the client is the one that sends most requests. The above also means that the server must have an addressable IP address. Probably in your situation that will not matter but it does mean you will need to figure out what the servers IP address is. ----------------------------- Now for your actual code whether your want the pc or arudino to be the server is up to you. (I know very little about the second but I expect it can act as both a server and client.) However I suggest that you start your learning experience using the PC only. So you will have two programs that run on your PC. One is the server. One is the client. You can google for examples of writing code exactly like that in C#. After you have tested that a bit then I suggest again only on the PC that you simulate what you want to actually do using the sample code. So for example if you want to send a specific command to the arudino then add code to do that in the PC code (client probably) and then respond in a pseudo way on the other side of the PC code. You might also want to figure out how to analyze problems while you are developing this. So for example you might do the following - PC server code to simulate arudino - Command received: Health check. Returns 'ok' - PC client code to send command - Command send: Health check - Use Console.WriteLine() to write the command to send (all information) - Use socket code to send it - Use socket code to recieve response - Use Console.WriteLine to write the response (all information.) You should also experiment with what happens when the IP address is wrong and what happens if the server is not running. ----------------------------------------------------------------------- As additional suggest for quite a bit in the future for a full application relying on Console.WriteLine() is not workable. So investigate 'logging'. You should not do this until you are comfortable with sockets.
-
Doesn't matter how you 'think' about the design the following is true. For TCP sockets there is always a 'server' and a 'client'. The 'server' creates a listener port and waits for a connection. The 'client' opens a socket to the server. So the client is the one that initiates the connection. After a connection is created either side can send and receive requests. Although often the client is the one that sends most requests. The above also means that the server must have an addressable IP address. Probably in your situation that will not matter but it does mean you will need to figure out what the servers IP address is. ----------------------------- Now for your actual code whether your want the pc or arudino to be the server is up to you. (I know very little about the second but I expect it can act as both a server and client.) However I suggest that you start your learning experience using the PC only. So you will have two programs that run on your PC. One is the server. One is the client. You can google for examples of writing code exactly like that in C#. After you have tested that a bit then I suggest again only on the PC that you simulate what you want to actually do using the sample code. So for example if you want to send a specific command to the arudino then add code to do that in the PC code (client probably) and then respond in a pseudo way on the other side of the PC code. You might also want to figure out how to analyze problems while you are developing this. So for example you might do the following - PC server code to simulate arudino - Command received: Health check. Returns 'ok' - PC client code to send command - Command send: Health check - Use Console.WriteLine() to write the command to send (all information) - Use socket code to send it - Use socket code to recieve response - Use Console.WriteLine to write the response (all information.) You should also experiment with what happens when the IP address is wrong and what happens if the server is not running. ----------------------------------------------------------------------- As additional suggest for quite a bit in the future for a full application relying on Console.WriteLine() is not workable. So investigate 'logging'. You should not do this until you are comfortable with sockets.