Post a New Reply
Reply to thread: Playing with AI
Username:
Post Subject:
Post Icon:
Your Message:
Smilies
Smile Wink Cool Big Grin
Tongue Rolleyes Shy Sad
At Angel Angry Blush
Confused Dodgy Exclamation Heart
Huh Idea Sleepy Undecided
[get more]
Post Options:
Thread Subscription:
Specify the type of notification and thread subscription you'd like to have to this thread. (Registered users only)





Attachments
Your allocated attachment usage quota is Unlimited.
New Attachment:


Thread Review (Newest First)
Posted by admin - 02-27-2026, 05:51 PM
been playing with AI going to put an AI chat bot online that you can communicate. Been experimenting with it, going work on the character background and lore. I might just put a different one on and let it loose.
Posted by admin - 02-26-2026, 05:46 PM
A multi-channel text-based P2P chat program


  1. Import the required libraries:
Quote:import socket
from threading import Thread, Lock


  1. Create server and client sockets:
Quote:HOST, PORT = 'localhost', 12345
# Server
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((HOST, PORT))
server_socket.listen()
print(f"Server listening on {HOST}:{PORT}")
# Client
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST, PORT = 'localhost', 12345
client_socket.connect((HOST, PORT))


  1. Implement a function to handle each client connection:
Quote:def handle_client(client_socket):
    while True:
        try:
            data = client_socket.recv(1024).decode('utf-8')
            print(data)
            # Send response back to the client
            response = input(f"Enter response for {data}: ")
            client_socket.send(response.encode('utf-8'))
        except Exception as e:
            print(e)
            break
    client_socket.close()


  1. Create a function to manage multiple clients:
Quote:def handle_connections(server_socket):
    connections = []
    lock = Lock()
    while True:
        client_socket, addr = server_socket.accept()
        print(f"Connected by {addr}")
        # Add the new connection to our list of connections
        with lock:
            connections.append(client_socket)
        # Start a new thread for each connected client
        client_thread = Thread(target=handle_client, args=(client_socket,))
        client_thread.start()

  1. Implement the main server loop to handle multiple clients:
Quote:def main():
    server_socket = create_server_socket()
    handle_connections(server_socket)
if __name__ == "__main__":
    main()