I am trying to do wireless communications between a PC and a Raspberry Pi using python's socket module. The problem is that the program on the PC is programmed in C# but the Raspberry-Pi is programmed in Python. How can I send a string from my computer so that the Raspberry Pi programmed in Python can read it?
-
2*I couldn't find any example of code doing this* yeah, sure – Selvin Jul 25 '19 at 08:57
-
1If you didn't find anything, perhaps you were too specific in your search terms? Typing "{language} tcp/ip samples" into your search engine of choice should bring up numerous results. – ProgrammingLlama Jul 25 '19 at 09:10
-
4It does not matter that one is in C# and one is in Python. As long as they follow the same protocol and use the same message format, you can get them talking to each other. – Gino Mempin Jul 25 '19 at 09:22
1 Answers
A protocol like this is language-independent. That is one advantage of having such a concept.
If a server receives a connection request, it doesn't know or care what kind of code was used to create the connection and send the data (someone could even be typing it in by hand, in theory), all it cares about is that the data being sent is in the correct format (as defined by the protocol) and the messages follow the correct sequence etc, so that it can understand it.
This applies to all sorts of commonly-known protocols, such as TCP/IP sockets, or higher-level protocols which build on that, such as HTTP or FTP.
So as long as you know how to create code to initiate a socket connection in language A, and code to listen for connections in language B (or C or D, or even A again), then everything should work correctly.

- 57,178
- 14
- 51
- 63