tcpsocket

Whats faster sending multiple small messages or less longer messages with TCP Sockets

你。 提交于 2021-02-07 09:23:15
问题 I can find any documentatin anywhere and would like to know what would be the best method of send multiple messages as fast as possible. for example if I had 300 devices recieivng messages from one server would it be better to send out one big message and have the devices pick out the parts that they need or send 300 messages but at 1/300 of the size. They would only be small stings so the 300 devies would only be getting 6 bytes each Does it make a difference? Thanks in advanced. 回答1: If the

TCP messages arrival on the same socket

梦想的初衷 提交于 2021-01-28 23:02:18
问题 I've got a 2 services that communicate using a TCP socket (the one that initiates the connection is a C++ Windows service and the receiver is a C# TCP stream) and (let's say that they might not use the same TCP connection all the time). Some of the time I'm getting half messages (where the number of bytes is miscalculated somehow) on a great network load. I have several questions in order to resolve the issue: Can I be sure that messages (not packets...) must follow one another, for example,

Mock TCPSocket in Rspec

余生长醉 提交于 2020-01-16 06:10:31
问题 I have a simple method which connects to a TCP server and puts single line of string and closes the connection. After the connection is closed the method redirects to a particular page. I am in interested in testing the redirection of that method and do not care about the TCP connection values. Thus, my best option to get around is to mock the connection. Here is the method, def print server = TCPSocket.new('a.b.c.d', 56423) server.puts "Hello Everyone" server.close redirect_to root_url end

Mock TCPSocket in Rspec

你说的曾经没有我的故事 提交于 2020-01-16 06:09:26
问题 I have a simple method which connects to a TCP server and puts single line of string and closes the connection. After the connection is closed the method redirects to a particular page. I am in interested in testing the redirection of that method and do not care about the TCP connection values. Thus, my best option to get around is to mock the connection. Here is the method, def print server = TCPSocket.new('a.b.c.d', 56423) server.puts "Hello Everyone" server.close redirect_to root_url end

How to disconnect from tcp socket in NodeJs

a 夏天 提交于 2020-01-11 17:23:13
问题 I connect to socket server in NodeJs using this command: client = net.createConnection() How can I then properly disconnect from the server? I tried client.end() and even client.destroy() but when I check the connection status using netstat it shows that the connection is in state FIN_WAIT2. How can I close and destroy the connection altogether? 回答1: net.createConnection() returns a Socket object. client.destroy() is what you want to do. Source: http://nodejs.org/docs/latest/api/net.html

Dotcloud www and TCP in single app -

纵饮孤独 提交于 2020-01-04 14:15:53
问题 I'm trying to get a nodejs socket server running that will allow remote communication between two clients running a Flash game that communicates using a custom protocol. Due to Flash security restrictions, it seems that the socket server must be running on the same host as the web server that servers the Flash game. I've been continuously getting the following error: The service crashed at startup or is listening to the wrong port. It failed to respond on port "nodejs" (8080) within 30

Ruby TCPSocket / HTTP request

微笑、不失礼 提交于 2020-01-02 10:35:32
问题 I just started with TCPSockets. I am simply trying to get the google home page. This is my code: require 'socket' host = 'http://www.google.com' port = 80 s = TCPSocket.open host, port s.puts "GET / HTTP/1.1\r\n" s.puts "Host: Firefox" s.puts "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" s.puts "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" s.puts "\r\n" while line = s.gets puts line.chop end s.close This returns: HTTP/1.1 302 Document has moved Location: http:/

Ruby TCPSocket: Find out how much data is available

我与影子孤独终老i 提交于 2019-12-21 05:21:13
问题 Is there a way to find out how many bytes of data is available on an TCPSocket in Ruby? I.e. how many bytes can be ready without blocking? 回答1: The standard library io/wait might be useful here. Requring it gives stream-based I/O (sockets and pipes) some new methods, among which is ready? . According to the documentation, ready? returns non-nil if there are bytes available without blocking. It just so happens that the non-nil value it returns it the number of bytes that are available in MRI .

Ruby TCPSocket: Find out how much data is available

六眼飞鱼酱① 提交于 2019-12-21 05:21:12
问题 Is there a way to find out how many bytes of data is available on an TCPSocket in Ruby? I.e. how many bytes can be ready without blocking? 回答1: The standard library io/wait might be useful here. Requring it gives stream-based I/O (sockets and pipes) some new methods, among which is ready? . According to the documentation, ready? returns non-nil if there are bytes available without blocking. It just so happens that the non-nil value it returns it the number of bytes that are available in MRI .

My linux application port is taken by another service when it's stopped

寵の児 提交于 2019-12-14 03:35:08
问题 I developed an application which contains a small http server. my application is launched in the boot. If I kill it (with kill -9 for example), the http server port will be taken directly by another daemon(acsd from broadcom). I tried the same behavior with drop-bear, but the problem is not reproduced. If I kill drop-bear the acsd does not take its port. here after the code of my server: void http_server_init(void) { struct sockaddr_in server; int cr_port; for(;;) { cr_port = conf.port; int i