Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7684157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:57:40+00:00 2026-05-31T18:57:40+00:00

I am making a simple client/server that will pass strings back and forth. It

  • 0

I am making a simple client/server that will pass strings back and forth. It is only slightly more advanced than an echo server. However, I am having some issue with passing the strings. I first ran into an issue where I was using the incorrect data type (not converting to utf-8), but am still having an issue.

Here is my server code:

import socket
import re 

host     = ''
port     = 15008
backlog  = 5 
size     = 1024
QUIT     = bytes("QUIT"    , "utf-8")
BYE      = bytes("BYE"     , "utf-8")
MATCH    = bytes("MATCH"   , "utf-8")
NO_MATCH = bytes("NO MATCH", "utf-8")

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
s.bind((host,port)) 
s.listen(backlog)

while 1: 
    client, address = s.accept() 

    regex = client.recv(size)
    if regex == QUIT:
        client.send(BYE)
        client.close()
        break

    string = client.recv(size)
    if string == QUIT:
        client.send(BYE)
        client.close()
        break

    if re.match(regex, string):
        client.send(MATCH)
    else:
        client.send(NO_MATCH)

and the client code:

import socket 

host = 'localhost' 
port = 15008
size = 1024

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
s.connect((host,port))

s.send(bytes('[ws]', "utf-8"))
s.send(bytes('s', "utf-8")) 
data = s.recv(size) 
print('Should match: ' + data)

s.close()

Right now both the server and client just get hung-up.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:57:41+00:00Added an answer on May 31, 2026 at 6:57 pm

    Needed to use decode.

    data = s.recv(size).decode("utf-8")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in making a simple cgi server for a course. To do that in some
I want to build a server/client engine for a game that I will eventually
I'm making a client/server pair with sockets to send and receive data back and
I'm practicing PyQt and (Q)threads by making a simple Twitter client. I have two
I am making a TCP chat server from a simple tutorial I found and
I am making a protocol, client and server which provide file transfer functionality similar
I am making a simple FTP client in Java using standard Java sockets. I
I'm making a simple http server and I want to add a world map
I've a Java client which accesses our server side over HTTP making several small
I want to create a simple long polling server in node.js where communication will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.