Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i put python socket chat client into renpy? #1118

Closed
decemer opened this issue Jan 24, 2017 · 1 comment
Closed

How can i put python socket chat client into renpy? #1118

decemer opened this issue Jan 24, 2017 · 1 comment

Comments

@decemer
Copy link

decemer commented Jan 24, 2017

How can i put python socket chat example client into renpy?

i run the server.py, and when i put

python:
        import socket
        import sys
        from thread import *
        HOST = ''   # Symbolic name meaning all available interfaces
        PORT = 8888 # Arbitrary non-privileged port

        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        #print 'Socket created'\
        "Socket created"
         
        #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'
         
        #Start listening on socket
        s.listen(10)
        print 'Socket now listening'
         
        #Function for handling connections. This will be used to create threads
        def clientthread(conn):
            #Sending message to connected client
            conn.send('Welcome to the server. Type something and hit enter\n') #send only takes string
             
            #infinite loop so that function do not terminate and thread do not end.
            while True:
                 
                #Receiving from client
                data = conn.recv(1024)
                reply = 'OK...' + data
                if not data: 
                    break
             
                conn.sendall(reply)
             
            #came out of loop
            conn.close()
         
        #now keep talking with the client
        while 1:
            #wait to accept a connection - blocking call
            conn, addr = s.accept()
            print 'Connected with ' + addr[0] + ':' + str(addr[1])
             
            #start new thread takes 1st argument as a function name to be run, second is the tuple of arguments to the function.
            start_new_thread(clientthread ,(conn,))
         
        s.close()

in renpy, it show nothing just ending,how to do that plz

@renpytom
Copy link
Member

renpytom commented Feb 5, 2017

This isn't a bug in Ren'Py.

@renpytom renpytom closed this as completed Feb 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants