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

  • Home
  • SEARCH
  • 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 7791085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:46:44+00:00 2026-06-01T21:46:44+00:00

Code: from socket import * sP = 14000 servSock = socket(AF_INET,SOCK_STREAM) servSock.bind((”,sP)) servSock.listen(1) while

  • 0

Code:

from socket import *
sP = 14000
servSock = socket(AF_INET,SOCK_STREAM)
servSock.bind(('',sP))
servSock.listen(1)

while 1:
  connSock, addr = servSock.accept()
  connSock.send('HTTP/1.0 200 OK\nContent-Type:text/html\nConnection:close\n<html>...</html>')
connSock.close()

When I go to the browser and type in localhost:14000, I get an error 101- ERR_CONNECTION_RESET The connection was reset? Not sure why! What am I doing wrong

  • 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-06-01T21:46:45+00:00Added an answer on June 1, 2026 at 9:46 pm

    Several bugs, some more severe than others … as @IanWetherbee already noted, you need an empty line before the body. You also should send \r\n not just \n. You should use sendall to avoid short sends. Last, you need to close the connection once you’re done sending.

    Here’s a slightly modified version of the above:

    from socket import *
    sP = 14000
    servSock = socket(AF_INET,SOCK_STREAM)
    servSock.bind(('',sP))
    servSock.listen(1)
    
    while 1:
      connSock, addr = servSock.accept()
      connSock.sendall('HTTP/1.0 200 OK\r\nContent-Type:text/html\r\nConnection:close\r\n\r\n<html><head>foo</head></html>\r\n')
      connSock.close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I only get the TCP message when I try this code: from socket import
I'm using those 2 pieces of code from http://wiki.python.org/moin/UdpCommunication The server: import socket UDP_IP=127.0.0.1
I am trying to use the code from Microsoft for an Async Socket connection.
The code below is reading 4 bytes from a socket into an integer. I
In the following code: tcp::socket socket(io_service); tcp::endpoint ep(boost::asio::ip::address::from_string(addr), i); socket.async_connect(ep, &connect_handler); socket.close(); is it
socket from c program sends 3 numbers to a socket in python. code and
from Tkinter import * import socket, sys, os import tkMessageBox root = Tk() root.title(File
Im trying to use this http://code.google.com/p/pywhois/ along with the socket.gethostbyaddr . import socket import
here is my code : import socket import sys import re import base64 import
I wrote two applictions which comunicate by socket. This is the code: Server: import

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.