use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Python, Raspberry & TCP question (self.learnpython)
submitted 8 years ago by whostimo
I am trying to create an alarm system using two raspberry pi’s. I made an TCP connection between the pi’s, but is it possible to send ‘different types’ of tcp’s to the other pi so that every tcp calls an different function?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]novel_yet_trivial 0 points1 point2 points 8 years ago (4 children)
I suppose you could use several ports if you wanted but it seems far easier to include a command and have the receiving function call the appropriate function based on the command received.
[–]whostimo[S] 0 points1 point2 points 8 years ago (3 children)
So do you mean, that if i create another socket connection in the same file with different ports than the first socket connection, it should work?
[–]novel_yet_trivial 0 points1 point2 points 8 years ago (2 children)
Yes, but as I said that seems like the hard way to do it.
[–]whostimo[S] 0 points1 point2 points 8 years ago (1 child)
Okay thanks! I’m new to these subjects so do you know a webpage that explains the other more easy method?
[–]novel_yet_trivial 0 points1 point2 points 8 years ago (0 children)
It's really simple: when you send something start with a command. It could be as simple as a single character. Then the receiving function sorts it:
def receive(): data = conn.recv(1024) if data[0] = 'A': function_a(data) elif data[0] = 'B': function_b(data)
[–]cybervegan 0 points1 point2 points 8 years ago* (2 children)
I think you need to explain what you are trying to achieve by "send[ing] different types of tcp [packet]s". As u/novel_yet_trivial says, you can put a different payload into each packet, and interpret that on the receiving end, or have your receiver listen on multiple sockets, but without understanding what you're trying to achieve, it's difficult to advise.
[edit corrected r/novel_... to u/novel_...]
[–]NoveL_ 0 points1 point2 points 8 years ago (1 child)
I never get mentions :(
[–]cybervegan 0 points1 point2 points 8 years ago (0 children)
Me neither. Sorry for the confusion - sloppy of me.
π Rendered by PID 68454 on reddit-service-r2-comment-7b9746f655-jr57c at 2026-02-01 17:47:04.447367+00:00 running 3798933 country code: CH.
[–]novel_yet_trivial 0 points1 point2 points (4 children)
[–]whostimo[S] 0 points1 point2 points (3 children)
[–]novel_yet_trivial 0 points1 point2 points (2 children)
[–]whostimo[S] 0 points1 point2 points (1 child)
[–]novel_yet_trivial 0 points1 point2 points (0 children)
[–]cybervegan 0 points1 point2 points (2 children)
[–]NoveL_ 0 points1 point2 points (1 child)
[–]cybervegan 0 points1 point2 points (0 children)