Monday 6 January 2020

Python : Dummy service on 9999 port in Linux

#!/usr/bin/python
# Demo server to open port 9999
# Modified from Python tutorial docs
import socket
import sys
HOST = 'localhost'   # IP addresses or Hostname
PORT = 9999 # Open non-privileged port 9999
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print 'Socket created Successfully'
#Bind socket to local host and port
try:
    s.bind((HOST, PORT))
except socket.error as msg:
    print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
    sys.exit()
print 'Socket bind complete'
#Started listening on socket
s.listen(10)
print 'Socket now listening'
while 1:
    #waiting to accept a connection - blocking call
    conn, addr = s.accept()
    print 'Connected with ' + addr[0] + ':' + str(addr[1])
s.close()

save the above file as port_server.py

run the port_server.py in one terminal & try telnet the hostname with 9999

SQL Developer displaying Junk characters (??????)

Change the Encoding in SQL Developer Preferences as below Tools --> Preferences --> Environment --> Encoding --> UTF...