I am a beginner in python and have been facing a problem. I am trying to create v4 only grpc server sockets based on the expectation that my code will need to run in ipv6 disabled environments.
My problem is that the following code does NOT create v4 sockets on address 0.0.0.0 by default.
To begin with, Here is a test file with output. Python version 2.7.5.
from gevent import monkey
monkey.patch_all()
from concurrent import patches
import grpc.experimental.gevent
grpc.experimental.gevent.init_gevent()
def main():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
server.add_insecure_port('0.0.0.0:50053')
server.start()
var = 1
while var == 1 :
pass
if __name__ == "__main__":
import sys
del sys.argv[1:]
sys.exit(main())
Output I see for "netstat -antop" on Centos 7 for port 50053 is :
tcp6 0 0 :::50053 :::* LISTEN 745/python off (0.00/0/0)
I want to get this :
tcp 0 0 0.0.0.0:50053 0.0.0.0:* LISTEN 1/python off (0.00/0/0)
Replacing
import grpc.experimental.gevent
grpc.experimental.gevent.init_gevent()
by
import grpc
makes this work.
Can you please help me understand?
Thanks in advance.