|
I found the answer:
It's a known issue in Edge version 126. The fix has been included in Stable 126.0.2592.81, which had been released on June 27, 2024. Please install the latest Edge Stable version 126.0.2592.81 (Official build) and test again.
|
|
|
|
|
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!
|
|
|
|
|
Hi
May be is was not clear , I don't have code written yet.
i want to get the idea how to create and manage many client sockets on my pc so i can select the socket i will send the data to by using the ip or other index
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.
|
|
|
|
|
|
Hello,
I have list checked box has items like "C:\" , "D:\" etc... and each item user can check or not. I need to test if current loop string value (drive) is checked or not in the list box
In addition I want to test "if not" condition for ex like this:
if (drive not in chklist_drives.CheckedItems) continue;
|
|
|
|
|
And?
What have you tried?
Where are you stuck?
What help do you need?
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?
That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!
"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!
|
|
|
|
|
Hold on. I did not that my question is vague . I have a list checked box that has items like "C:\", "D:\" etc...
and I need to check current string value in a loop if that value is checked or not in the list box
What I tried:
I have a loop like this:
foreach (drive in all drives)
{
if (drive not in chklist_drives.CheckedItems) continue;
}
Thats it I dont know how I can implement this if line of code
|
|
|
|
|
As you have discovered, drive not in chklist_drives.CheckedItems is not valid C#.
Assuming this is a Windows Forms CheckedListBox control, the CheckedItems collection provides a Contains method to test whether an item is in the collection:
CheckedListBox.CheckedItemCollection.Contains(Object) Method (System.Windows.Forms) | Microsoft Learn[^]
But you're also going to find that foreach (drive in all drives) is not valid C# either. Perhaps you're looking for the System.IO.DriveInfo.GetDrives method[^]?
foreach (DriveInfo drive in DriveInfo.GetDrives())
{
if (!drive.IsReady) continue;
if (!chklist_drives.CheckedItems.Contains(drive.Name)) continue;
...
} You'll need to adjust that code so that the value you check for in the list matches the value you added to the list in the first place.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks alot. Second if is what I need.
|
|
|
|
|
Now compare that against your original question and it should be obvious why it took you 8 hours to get an answer!
If you give us details we can help a lot quicker!
"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!
|
|
|
|
|
Hi,
I'm currently learning how to use Entity Framework Core and I'm trying to create a "more advanced" application divided into multiple projects.
When I was using ADO.NET, I would usually make:
- Project.DatabaseAccess - for managing connection strings,
- Project.Shared - base classes and interfaces (which implement INotifyPropertyChanged)
- for example Project.Customers - models for customer-related stuff and a static class with CRUD methods for them.
Customers would then reference the Shared and DatabaseAccess projects.
When using EfCore, I wanted to achieve similar structure, so:
- Project.DatabaseAccess - managing connection strings, main DbContext
- Project.Shared,
- Project.Customers - models for customer-related stuff and repositories for them (with DbContext provided in the constructor)
The problem with that approach is that Customers reference to the DatabaseAccess (for accessing DbContext), and DatabaseAccess needs to reference to the Customers (because it has DbSet<customer>). Unfortunately, you can't make A<-->B references in the Visual Studio.
What other project structures do you recommend? I know that there is something called CleanArchitecture (Application, Domain, Infrastructure), but it doesn't provide the separation between different spheres of my program (Project.Customers, Project.Planning, Project.Mailing, etc.)
Thank you in advance!
|
|
|
|
|
nwbkn wrote: you can't make A<-->B references in the Visual Studio
You can use interfaces for circular references.
nwbkn wrote: Customers reference to the DatabaseAccess
Your Data API layer accepts DTOs (Data Transfer Object) and returns DTOs. So 'Customer' is a DTO which the CustomerDB class uses. Although you can choose your own names for the classes.
Create Data Transfer Objects (DTOs) | Microsoft Learn[^]
Be very careful about what you put in a DTO. Probably to start out you should have nothing but properties.
|
|
|
|
|
|
jschell wrote: You can use interfaces for circular references. I learn something new every time I visit this website!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
difficulties gives us new challenges and something new to learn.
|
|
|
|
|
Hi,
I have downloaded Visual Studio to write and run C# scripts.
Can I use Microsoft SQL Manager for free to use with C# to create windows database apps?
Or do you suggest another free DB to use? or even another app to run C#?
Basically I want to get my Grand Daughter into programming using C# for, well FREE
Any suggestions and code examples greatly appreciated.
Thanks
|
|
|
|
|
|
Thank you for the quick response, really appreciated
|
|
|
|
|
You're welcome! Good luck with the granddaughter - teaching isn't as easy as some people think ...
"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!
|
|
|
|
|
|
Excellent, Thank you very much
|
|
|
|
|
Note that the current revision (1.1) of the book is more than 17 years old. Don't expect it to cover all the new bells & whistles. A few things have been added since C# version 2.0 and dotNet 3.0, so don't expect to learn enough to understand all the sample code you'll find on the internet today.
Do read the book - Petzold is a top notch technical writer, and most certainly for beginners. Just be prepared to discover that there is a lot more to C#/dotNet today that Petzold couldn't possibly have described in his 2006-2007 book.
Additional comment: Once you are through Petzold, a nice way to learn about more recent additions is to read The history of C#[^] bottom up. The links to the descriptions of each new extension is mostly quite readable!
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
I don't think you meant this message for me.
|
|
|
|