Click here to Skip to main content
15,946,320 members
Home / Discussions / C#
   

C#

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder12-Jul-09 22:36
cofounderChris Maunder12-Jul-09 22:36 
PinnedHow to get an answer to your question Pin
Chris Maunder10-Nov-05 16:31
cofounderChris Maunder10-Nov-05 16:31 
QuestionDPI issue when calling C# from C++ Pin
JudyL_MD14hrs ago
JudyL_MD14hrs ago 
AnswerRe: DPI issue when calling C# from C++ Pin
Richard Andrew x6412hrs 57mins ago
professionalRichard Andrew x6412hrs 57mins ago 
GeneralRe: DPI issue when calling C# from C++ Pin
JudyL_MD7hrs 39mins ago
JudyL_MD7hrs 39mins ago 
QuestionLog file advice? Pin
geomeo12318-Jul-24 15:12
geomeo12318-Jul-24 15:12 
AnswerRe: Log file advice? Pin
jschell19-Jul-24 13:24
jschell19-Jul-24 13:24 
GeneralRe: Log file advice? Pin
Richard Andrew x6420-Jul-24 14:37
professionalRichard Andrew x6420-Jul-24 14:37 
QuestionTables not appearing as classes Pin
Hesam emami9-Jul-24 23:17
Hesam emami9-Jul-24 23:17 
AnswerRe: Tables not appearing as classes Pin
Dave Kreskowiak10-Jul-24 2:56
mveDave Kreskowiak10-Jul-24 2:56 
GeneralRe: Tables not appearing as classes Pin
Hesam emami10-Jul-24 11:37
Hesam emami10-Jul-24 11:37 
GeneralRe: Tables not appearing as classes Pin
Dave Kreskowiak10-Jul-24 11:44
mveDave Kreskowiak10-Jul-24 11:44 
AnswerRe: Tables not appearing as classes Pin
RedDk10-Jul-24 14:15
RedDk10-Jul-24 14:15 
QuestionPrint and Print Preview of Web Page not Working Properly in Microsoft Edge Browser Pin
Fokwa Divine3-Jul-24 3:54
Fokwa Divine3-Jul-24 3:54 
AnswerRe: Print and Print Preview of Web Page not Working Properly in Microsoft Edge Browser Pin
jschell3-Jul-24 6:00
jschell3-Jul-24 6:00 
GeneralRe: Print and Print Preview of Web Page not Working Properly in Microsoft Edge Browser Pin
Fokwa Divine3-Jul-24 6:05
Fokwa Divine3-Jul-24 6:05 
AnswerRe: Print and Print Preview of Web Page not Working Properly in Microsoft Edge Browser Pin
RedDk3-Jul-24 6:54
RedDk3-Jul-24 6:54 
GeneralRe: Print and Print Preview of Web Page not Working Properly in Microsoft Edge Browser Pin
Fokwa Divine3-Jul-24 7:20
Fokwa Divine3-Jul-24 7:20 
GeneralRe: Print and Print Preview of Web Page not Working Properly in Microsoft Edge Browser Pin
RedDk3-Jul-24 7:54
RedDk3-Jul-24 7:54 
GeneralRe: Print and Print Preview of Web Page not Working Properly in Microsoft Edge Browser Pin
Fokwa Divine9-Jul-24 2:31
Fokwa Divine9-Jul-24 2:31 
Questionmulti tcp clients Pin
darinka2-Jul-24 10:56
darinka2-Jul-24 10:56 
AnswerRe: multi tcp clients Pin
OriginalGriff2-Jul-24 21:37
mveOriginalGriff2-Jul-24 21:37 
GeneralRe: multi tcp clients Pin
darinka3-Jul-24 2:05
darinka3-Jul-24 2:05 
AnswerRe: multi tcp clients Pin
jschell3-Jul-24 6:14
jschell3-Jul-24 6:14 
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.
GeneralRe: multi tcp clients Pin
darinka3-Jul-24 6:59
darinka3-Jul-24 6:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.