Opening public socket with python in Cloud9 - python

I am trying to make a simple and very low level UDP server on Cloud9.
What I would like to do is to open an UDP socket on some port and some ip so that it is accessible from the extern and so that I can get an incoming UDP packet.
I tried to do something like
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(("", 12345))
But then I wouldn't know the ip. I naively tried to do an ifconfig but I got an ip that I couldn't even ping.
I found out about the IP and PORT environment variables, but IP is always 0.0.0.0.
Is there any way to do what I need?

Sorry to disappoint you, but that is not possible. At this moment only TCP port 8080 in the workspace can be accessed from the internet. So you can develop the UDP server and test its functionality from the same workspace, but to make it work from external sources you should deploy the code to a hosting provider.

Related

I cannot connect to my own IRC server with python socket

I am Japanese and I am not good at speaking English. Please let me know if there is anything I say that you don't understand.
I have a question regarding Python's socket module.
I am setting up an IRC server on a virtual machine and I am trying to create an IRC bot with Python, but I am unable to connect to the server.
I have tried the following minimal code:
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(5) # set timeout to 5 seconds
sock.connect(('xxx.xx.xxx.xx', 6667))
However, it times out and I am unable to connect. I have checked the server's IP address using ping and it returns a response. The virtual machine is running CentOS 7 and both SElinux and firewall are disabled. Ruby code works properly and LimeChat2 on my local PC can also connect without any issues.
Please let me know what could be the possible reasons for this issue. The port number is correct.

How to set different IP for client and server running on same machine?

I used socket module and localhost IP address 127.0.0.1 and both client and server are under same IP (codes written in python and socket modules are imported)
How I use different IP address to server and client if you know please let me know it’s very important

Run DNS server on own ip

I'm implementing a simple DNS server, which I want to run on my pc. But, as far as I understand the combination of my IP and port 53 (standard DNS server port) is already occupied.
This is how I tried to open socket:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('', 53))
This is an error message I get:
socket.error: [Errno 98] Address already in use
But, when I use 127.0.0.1 as IP address when creating a socket, everything works fine and I'm able to get requests.
This is what have tried so far (in Linux terminal I tried to kill the socket):
fuser -k -n udp 53
But it didn't work. So how can I run DNS server on my own IP address?

ZeroMQ (TCP) workaround for port forwarding

I currently have a ZeroMQ peer to peer network I'm building using Python and PyZMQ. Currently the server listens with a REP TCP socket and connects directly to other peers listening on the same type of socket. This requires port forwarding for clients to get to the servers sadly though. Is there anyway to get around this? Can I do some kind of UDP discovery and then switch over to TCP? Or am I doomed to switch to a UDP style network to solve this problem?

Incoming ZeroMQ traffic dropped by server due to NAT?

I have a ZMQ server listening on port 12345 TCP. When another server connects on that port locally or via VM it works fine, but if I try from a remote server that has to go through port forwarding on my Fios firewall it just bombs. The packets are showing up in Wireshark but ZMQ just ignores them. Is there anyway to get past this?
You shouldn't be able to bind more than once to the same port number, either from the same process or another.
ZMQ should give a failure when you issue bind with a port number already in use. Are you checking return codes?

Categories

Resources