#🔒 socket

66 messages · Page 1 of 1 (latest)

sand ocean
#

translator portuguese for english = TimeoutError: [WinError 10060] A connection attempt failed because the connected component did not respond
correctly after a period of time or the established connection failed
because the connected host did not respond

rough otterBOT
#

@sand ocean

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

sleek garden
hushed zodiac
#

I think it's the extra () around HOST and PORT

finite path
#

!d socket.socket.connect

rough otterBOT
#

socket.connect(address)```
Connect to a remote socket at *address*. (The format of *address* depends on the address family — see above.)

If the connection is interrupted by a signal, the method waits until the connection completes, or raises a [`TimeoutError`](https://docs.python.org/3/library/exceptions.html#TimeoutError) on timeout, if the signal handler doesn’t raise an exception and the socket is blocking or has a timeout. For non-blocking sockets, the method raises an [`InterruptedError`](https://docs.python.org/3/library/exceptions.html#InterruptedError) exception if the connection is interrupted by a signal (or the exception raised by the signal handler).

Raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `socket.connect` with arguments `self`, `address`.
hushed zodiac
#

But i can't read the error so

#

Oh actually

finite path
#

no, that's right

finite path
hushed zodiac
#

You need root to run port 80

#

Oh ok nvm

#

Idk shit

sleek garden
#

yea it does not feel correct

#

228

#

and not ipv6 either

hushed zodiac
#

228 is valid

#

As long as it's less than 256

sleek garden
#

oh right

sand ocean
# sleek garden hey can u copy the code and send it here as text

import socket

HOST = "4.228.31.150"
PORT = 80

C = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
C.connect((HOST, PORT))
if C.connect:
print("Connected")

Request HTTP basic

C.send(b"GET / HTTP/1.1\r\nHost: github.com\r\n\r\n")

resposta = C.recv(4096)

if resposta:
print(resposta.decode(errors="ignore"))
else:
print("not response")

C.close()

rough otterBOT
#

Hey @sand ocean!

Please edit your message to use a code block

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
shell patio
#

for port?
Ports below 1024 are typically reserved

sand ocean
hushed zodiac
#

I can't read the language

finite path
#
import socket

host = socket.getaddrinfo("github.com", 80)[0]

socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

socket.connect(host[4])

socket.send(b"GET / HTTP/1.1\r\nHost: github.com\r\n\r\n")

response = socket.recv(4096)
print(response.decode(errors="ignore"))``` this works for me @sand ocean
#

also if C.connect is always True because socket.socket is a function, not a boolean value

sand ocean
# hushed zodiac I can't read the language

TimeoutError: [WinError 10060] A connection attempt failed because the connected component did not respond
correctly after a period of time or the established connection failed
because the connected host did not respond

finite path
hushed zodiac
#

Ok ty

finite path
finite path
#

example:

$ nslookup google.com
Server:        127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
Name:    google.com
Address: 142.251.34.238
Name:    google.com
Address: 2607:f8b0:4009:800::200e```
sand ocean
#

same error @finite path

finite path
#

hm

sand ocean
finite path
#
$ uv run test.py
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Location: https://github.com/``` i got this
sand ocean
#

It takes me a while to answer because I'm translating, I don't speak English

finite path
#

can you try a different url instead of github.com? try google or something

sand ocean
#

google ✅

#

why is github not responding?

#

firewall?

finite path
#

idk

#

beats me

sand ocean
pale obsidian
#

Is it with every link?

#

You dont have any proxies or such configured do you?

#

Also check your firewall isn't blocking it

sand ocean
#

I really think the GitHub firewall is ignoring it.

pale obsidian
#

Ok i think github requires a tls handshake

#

Otherwise it just rejects the request

#

Why dont u just use the requests library?

sand ocean
#

it makes sense

sand ocean
rough otterBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.