Questions tagged [python-sockets]

For questions related to the sockets module in the Python standard library, or more broadly socket programming in Python.

The Python library comes with a HOWTO document for sockets programming:

Socket Programming HOWTO — Python 3.x documentation

The standard library is well-documented:

socket - Low-level networking interface

Like the title suggests, sockets are the basic facility for network connections, and on Unix, several other types of interprocess connections. Beginners who want to use a particular application-level protocol should often try to find an existing higher-level library for that instead of programming directly with sockets.

506 questions
0
votes
1 answer

i am not able to send the complete text, as soon as i enter a character i get a reply and the connection closes.(i am new to python sockets)

import socket import sys host='' # Symbolic name meaning all available interfaces port=7777 #random port #creating socket sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM) print "socket created" #binding try: …
Aashish
  • 1
  • 1
0
votes
1 answer

Python sockets not sending data immediately

I am making a game in python. It uses sockets. It is my first time using sockets. Here is part of my code: serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # get…
Sid Prasad
  • 137
  • 1
  • 2
  • 10
0
votes
1 answer

Python 3.4 Rock paper scissors with socket and pyqt5

I am new to programming and I have some problems with my programm. Wish someone can help me I am trying to create a rock-paper-scissors game on Python using socket and pyqt5. My programm worked when I ran it without using pyqt5, but after trying to…
Postal
  • 1
  • 1
0
votes
1 answer

What is wrong with my python socket script?

I wrote a short class to help me test sending plain text http requests to a server that I'm working on, but none of the requests I make with it are going through, even requests to domains other than my server. All requests are timing out. The class…
bgenchel
  • 3,739
  • 4
  • 19
  • 28
0
votes
0 answers

How to open ssh tunnel between 2 different machine not on the same network?

I tried below code: #!/usr/bin/python import socket,subprocess HOST = '78.163.XX.XX' PORT = 22 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST,PORT)) s.send('[*] Connection Established!') while 1: data =…
erginduran
  • 1,678
  • 5
  • 28
  • 51
0
votes
1 answer

Python: Wait for "child process termination" OR "new connection"

I need to implement something like this: while True: conn,addr = socket.accept() restore() p.kill() #... p = subprocess.Popen(...) But I need that the restore() function is called not only after every new connection, but also…
0
votes
1 answer

How to make TCPServer multiprocessing

I'm using TCPHandler to precess TCP requests from client sockets, but I encountered the performance issue when I was using multiThreading, the snippet code as following: class TCPHandler(SocketServer.StreamRequestHandler): def handle(self): …
Jack
  • 5,540
  • 13
  • 65
  • 113
0
votes
1 answer

Set timeout for Python socket when sending data out

I would like to set timeout for Python socket client. That means, socket client connects to server then sends data within 1 second. If it takes more than 1 second, the method would raise some kind of exception or error. Here is my source code: def…
duong_dajgja
  • 4,196
  • 1
  • 38
  • 65
0
votes
1 answer

How to send SNMP notification to private subnet in python?

I'm trying to write simple python app to send SNMP traps. I've already wrote MIB table and sending traps to localhost works fine. from pysnmp.entity.rfc3413.oneliner import ntforg ntfOrg = ntforg.NotificationOriginator() errorIndication =…
kostr22
  • 576
  • 7
  • 27
0
votes
1 answer

Regarding Python's socket module, how do you have client always receive data

I a server and client for a socket connection in Python, client: import socket import sys from sys import stdin serv = 'ip goes here' port = 8888 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((serv, port)) def prompt(): …
user2896775
  • 182
  • 1
  • 1
  • 8
0
votes
0 answers

Python tcp socket, how to get data from an async server

I've never done python programming before, so I'm hoping you guys can give me some feedback in my code. I have a node js tcp server that must receive a json "request" object and then will respond with several other json objects, asynchronously. I…
lucaswxp
  • 2,031
  • 5
  • 23
  • 34
0
votes
1 answer

sending images using python tcp socket

i'm new in python and english :). i'm trying to send an image file usşng python sockets and i have written this cosdes. it says it work but i get an empty file or missing image file. this is the codes i've written: server: import socket host =…
Ali Şıvgın
  • 61
  • 1
  • 2
  • 7
0
votes
1 answer

Reading in image as binary for http server python 3.4

Alright first off I want to point out that no networking libraries can be used. The purpose of what I'm trying to do is learn how http 1.1 headers and data are to be served using string manipulation/conversions. In this case I'm trying to serve a…
0
votes
1 answer

Failure in arp poisoning python (linux)

Okay, so I'm running Ubunutu 14.04 LTS, and I'm trying to poison my own ARP Cache, by doing this, my private IP address is 10.0.0.1. My phone's private IP address is 10.0.0.8. for this example only let's say my MAC address is axaxaxaxaxax. I've…
user3687265
  • 103
  • 3
  • 12
0
votes
0 answers

Failure to send raw ip packets in python

First of all I'm using Windows 7, (I've read that this might be causing my problems), I'm trying to send a RAW IP packet with a customized IP header using python, but when I'm trying to catch it with wireshark, I manage to catch a packet, but the…
user3687265
  • 103
  • 3
  • 12