tcpserver

Simple One Thread Socket - TCP Server

笑着哭i 提交于 2020-12-04 05:16:50
问题 First, I don't know if Stackoverflow is the best site to post this kind of message, but I don't know another sites like this. In oder to understand properly tcp programmation in C#, I decided to do all possible ways from scratch. Here is what I want to know (not in the right order: - Simple One Thread Socket Server (this article) - Simple Multiple Threads Socket Server (I don't know how, cause threads are complicated) - Simple Thread Socket Server (put the client management in another thread)

C# Socket.receive continuously receives 0 bytes and does not block in the loop

北慕城南 提交于 2020-01-13 09:23:13
问题 I am trying to write a simplest multithreaded TCP server in C#, which receives the data from multiple clients. Every time a new client is connected, the socket connection is established and the socket is passed as an argument to the new class function, after that the while loop runs and receives the data till the client is connected. The problem here is that the "socket.receive" is not blocking and receives 0 bytes of data. So the loop runs continuously, without blocking at socket.receive (

How to add logging to a file with timestamps to a Python TCP Server for Raspberry Pi

故事扮演 提交于 2020-01-12 07:44:05
问题 I am kinda stuck for my project & I desperately need help. I need a simple TCP server python code that has features like logging & time stamp which I could use for my Raspberry Pi. Its for my Final Year Project. I've looked at some examples, but as I don't have much experience in writing my own scripts/codes, I'm not very sure how to go about doing this. I would appreciate if someone could guide me in the right direction with explanation and some examples if possible. I am using HERCULES

Create WebSockets between a TCP server and HTTP server in node.js

ぃ、小莉子 提交于 2020-01-11 19:41:32
问题 I have created a TCP server using Node.js which listens to clients connections. I need to transmit data from TCP server to HTTP server again in Node.js possibly through a Websocket ( socket.io ). However, I do not know how to create such connection such that TCP server is able to push data to HTTP server through Websocket. Many Thanks. 回答1: I was trying lot of things to get this work. Most of the time I was relying on socket.io to get this working, but it was just not working with TCP.

how to stream audio with tcpserversink using gstreamer

做~自己de王妃 提交于 2020-01-06 06:44:15
问题 I need live-stream audio over Internet. Quick search in internet and I decide using Gstreamer. I has streamed successfully using udpsink, but it only work on LAN. I test with tcpserversink but it not working: Server (IP: 113.160.166.87) gst-launch-1.0 filesrc location="G:/Project/Gstreamer/TestContent/Em-Gai-Mua-Huong-Tram.mp3" ! decodebin ! mulawenc ! tcpserversink port=7001 host=0.0.0.0 Client: gst-launch-1.0 tcpclientsrc host=113.160.166.87 port=7001 ! "audio/x-mulaw, channels=1, depth=16,

How to test a multi-threaded TCPServer with rspec

坚强是说给别人听的谎言 提交于 2020-01-04 06:10:51
问题 I've written a really simple date server: require 'socket' s = TCPServer.new 3939 while (conn = s.accept) Thread.new(conn) do |c| c.print "Enter your name: " name = c.gets.chomp c.puts "Hi #{name}, the date is..." c.print `date` c.close end end A user connects, a thread is spawned, they enter their name, the date is returned. Simple. I'm wondering about how I would go abouts testing something like this in rspec. Some ideas that I've had: 1.) Use VCR to record a server connection and Timecop

How to test a multi-threaded TCPServer with rspec

◇◆丶佛笑我妖孽 提交于 2020-01-04 06:10:04
问题 I've written a really simple date server: require 'socket' s = TCPServer.new 3939 while (conn = s.accept) Thread.new(conn) do |c| c.print "Enter your name: " name = c.gets.chomp c.puts "Hi #{name}, the date is..." c.print `date` c.close end end A user connects, a thread is spawned, they enter their name, the date is returned. Simple. I'm wondering about how I would go abouts testing something like this in rspec. Some ideas that I've had: 1.) Use VCR to record a server connection and Timecop

How to put tcp server on another thread in python

北城以北 提交于 2020-01-04 05:54:45
问题 I try to write a daemon in python. But I have no idea how can I use a thread to start parallel tcp server in this daemon. And even what type of server I should use : asyncore?SocketServer?socket? this is part of my code: import os def demonized(): child_pid = os.fork() if child_pid == 0: child_pid = os.fork() if child_pid == 0: #fork twice for demonize file = open('###', "r") # open file event = file.read() while event: #TODO check for changes put changes in list variable event = file.read()

how create TCP server by ESP8266?

六月ゝ 毕业季﹏ 提交于 2020-01-01 03:40:33
问题 I want to create a simple Wifi TCP server by ESP8266 in Arduino IDE. But I have a big problem: when I send a character or string from client I can't receive it on the server. In fact I connect esp8266 to my PC and I want to see send character from client in pc terminal. my sending side is Socket protocol app for android!and complete code I write in sever side is: WiFiServer server(8888); void setup() { initHardware(); setupWiFi(); server.begin(); } void loop() { WiFiClient client = server

TCPserver without OnExecute event

情到浓时终转凉″ 提交于 2019-12-30 07:00:09
问题 I want to make a TCPserver and send/receive message to clients as needed , not OnExecute event of the TCPserver. Send/receive message is not a problem; I do like that: procedure TFormMain.SendMessage(IP, Msg: string); var I: Integer; begin with TCPServer.Contexts.LockList do try for I := 0 to Count-1 do if TIdContext(Items[I]).Connection.Socket.Binding.PeerIP = IP then begin TIdContext(Items[I]).Connection.IOHandler.WriteBuffer(Msg[1], Length(Msg)); // and/or Read Break; end; finally