Code: Select all
import socket
if s.type is socket.SocketKind.SOCK_STREAM:
# do stuff with TCP socket
elif s.type is socket.SocketKind.SOCK_DGRAM:
# do stuff with UDP socket
Code: Select all
import socket
if s.type is socket.SocketKind.SOCK_STREAM:
# do stuff with TCP socket
elif s.type is socket.SocketKind.SOCK_DGRAM:
# do stuff with UDP socket
Yeah, I had already taken the "easy" route. It is just a bit more messy in my code.jimmo wrote: ↑Sat Aug 10, 2019 5:32 amThis is not currently implemented. I guess they left it out for space reasons because you'd assume that whatever created the socket either knew what type it was at creation, or it was accept'ed from a known socket type.
If you were interested in implementing this yourself, look at modlwip.c. The underlying lwip_socket_obj_t type has a `type` member. So it would be fairly straightforward to expose this to Python. But it may be easier just to keep track of this in your Python code.
I guess you could subclass socket to create one with a type bound variable or property.manseekingknowledge wrote: ↑Sun Aug 11, 2019 2:36 am...
Yeah, I had already taken the "easy" route. It is just a bit more messy in my code.