tcpserver

Python NameError: name 'name' is not defined [closed]

不羁的心 提交于 2019-12-27 06:19:07
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I am doing socket programming in python and finding a message. This is my code..... import socket def Main(): host = '127.0.0.1' port = 5000 s = socket.socket() s.bind((host,port)) s.listen(2) c, addr = s.accept() print "Connecton from : " + str(addr) while True: data = c.recv(1024) if not data: break print

HTML5 web sockets - how to communicate with them?

江枫思渺然 提交于 2019-12-25 01:49:59
问题 I've tested many socket examples and communication between them was pretty simple: socket is opened and stays open until you close it and no information is being sent except the one you have sent. With HTML5 web sockets these two moments are different. At first, as soon as the client HTML5 socket connects to server socket it sends a bunch of information: GET /echo HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: localhost:2002 Origin: null Pragma: no-cache Cache-Control: no-cache Sec

Python3 TCP Server not seeing incoming messages from external device

ぐ巨炮叔叔 提交于 2019-12-24 18:52:47
问题 I want to create a small TCP server that takes incoming TCP connections from a device that is hooked up via Ethernet to my computer. The physical port for that has the IP 192.168.1.100 statically assigned to it. The scripts I use as a client and server are listed at the bottom. The setup works if I want to send messages between the python scripts. However, I am unable to receive anything from the external device (screenshot from Wireshark capture below). From what I have read I can define an

Cannot telnet to Xamarin Android app that runs as a server

那年仲夏 提交于 2019-12-24 11:29:59
问题 I have created a Xamarin Forms app that implements the code found here to setup an endpoint: https://docs.microsoft.com/en-us/dotnet/framework/network-programming/asynchronous-server-socket-example I have added INTERNET permission in AndroidManifest.xml as follows: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.Server"> <uses-sdk android:minSdkVersion="21"

Python TCP Server using select()

三世轮回 提交于 2019-12-24 07:49:46
问题 this is my first entry @stackoverflow;-)) I need a Python3 TCP server, which sends all inputs of the clients to the other participants. The server works, but unfortunately the message is only returned to the sending client. As soon as the second client sends something, it gets all entries.The entries are therefore available in the output queue. Why are the entries not recognized by select ()? Thx for the support. ` import select import socket import sys import queue server = socket.socket

Delphi XE2 / Indy TIdTCPServer / “Connection reset by peer”

半腔热情 提交于 2019-12-24 00:28:00
问题 I'm with one problem using Indy in Delphi XE2 to send TCP Messages using TIdTCPServer. For exemple: I have 2 devices and i'll go communicate with device 1. When i send messages to device 1, the messages were send fine. But without close the program, when i send messages to device 2, Delphi returns "Connection reset by peer". Below is my code: procedure TMainHost.idTCPServerNewConnect(AContext: TIdContext); var Client: TSimpleClient; begin Sleep(1000); Client := TSimpleClient.Create(); Client

Correct way to detect a client has disconnected from TCP/IP

◇◆丶佛笑我妖孽 提交于 2019-12-21 20:03:33
问题 I have used a Asynchronous TCP/IP server, everything works fine but when a client disconnects due to error or forced exit of the application it also closes my server due to an exception of type IO.IOException. The exception occurs in the following sub: Private Sub ReadCallback(ByVal result As IAsyncResult) Try Dim client As Client = TryCast(result.AsyncState, Client) If client Is Nothing Then Return End If 'MsgBox(client.ClientID) Dim networkStream As NetworkStream = client.NetworkStream Dim

TcpListener vs SocketAsyncEventArgs

假装没事ソ 提交于 2019-12-19 09:04:08
问题 Is there a valid reason to not use TcpListener for implementing a high performance/high throughput TCP server instead of SocketAsyncEventArgs ? I've already implemented this high performance/high throughput TCP server using SocketAsyncEventArgs went through all sort of headaches to handling those pinned buffers using a big pre-allocated byte array and pools of SocketAsyncEventArgs for accepting and receiving, putting together using some low level stuff and shiny smart code with some TPL Data

Faster way to communicate using TcpClient?

好久不见. 提交于 2019-12-18 03:34:09
问题 I'm writing a client/server application in C#, and it's going great. For now, everything works and it's all pretty robust. My problem is that I run into some delays when sending packets across the connection. On the client side I'm doing this: NetworkStream ns = tcpClient.GetStream(); // Send packet byte[] sizePacket = BitConverter.GetBytes(request.Length); byte[] requestWithHeader = new byte[sizePacket.Length + request.Length]; sizePacket.CopyTo(requestWithHeader, 0); request.CopyTo

C# High CPU usage on Listener thread, sleeping misses disconnect

左心房为你撑大大i 提交于 2019-12-17 17:10:48
问题 My connection handler is below (this is more for personal experimentation than production code) If I don't add a Thread.Sleep anywhere in the while loop, it starts sucking down CPU.. Conversely, if I do Sleep to alleviate the endless while-spam, I miss the disconnection.. The CPU goes up in direct proportion to the number of clients/threads running, so it's not the listener itself that's causing the high usage, it's the actual client thread posted below.. Anyone have any ideas on how to solve