Decrease latency for TCP stack [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Hi I have a PC(A) that receive data via TCP and need forward them to other PC(B)server.
The problem is PC(B) server can open only few sessions about 5 and we need to connect it to about 100 clients and we want to do it via PC(A) that read data and add id to data and forward it to server.
for do that I write a simple tcp server(run on PC A), that read data from TCP stack and forward it to PC(B)
I accept the connection on an open socket and forward it to PC(B).
In this PC(A) take about 200 μs to do this data forwarding. I have 3 GHZ * 10 and I use fedora OS, my data is so small.
How I can decrease this latency?
Do I need to change my OS or make any optimization that decreases this latency?

Related

C++ Direct Access To Wires [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am wanting to create a c++ program that will power cables.Like a ethernet cable has several wires in it.How would I choose a wire and send current through it?
If anyone can explain how to send current over specific wires that would be great.I also do not want to use a library.To make it even clearer , I wish to be able to do something like this [Video] https://www.youtube.com/watch?v=H1enhkLZm10 .
I guess this will answer your question: I/O Ports controlled LEDs.
This is a code snippet from the website on how to communicate with a port:
#include <conio.h>
#include <dos.h> // For _out
#define port 0x378 // Port Address
#define data port+0 // Data Port of the parallel cable
void main (void)
{
_out(data, 255); // For all lights on
_out(data, 0); // For all lights off
}
If you don't know how computers communicate with peripherals, and how different ports like USB(Universal Serial Bus), Serial ports, and other ports communicate and work. This guide should help you get started.Control Physical World Through Computer (Step by Step)

How to open a UDP port? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have an assignment that I need to write a program that opens a port in the network, than I should check if the port is opened in another machine using nmap or netcat.
Well, I already did that.. but I did it using socket, I created a socket then binded and keep listening, that's the only way I know to do it. is there a better way ? because my way doesn't seem write..
Also, is opening a port for TCP is different then a port for UDP ?
Note: I'm trying to figure out how to write a program that open a port in C/C++, but Python or Java are fine too..
Edit: I'm fine with TCP, but still didn't figure out how to open a port for UDP. Since there's no "listen" in UDP, how am I supposed to keep the port open ? I wrote a program that creates a socket for UDP and binds it, but when I scan it with nmap, it says "open/filtered", how am I supposed to make it only Open ?
That is the correct way to "open" a port.
A port is called "open" if something is listening on it. So, by definition, you need to listen on a port for it to become open.

C++ Streaming audio from microphone [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have got a classic client-server environment in c++.
Now i want to implement a voice chat between specific clients.
My problem is: How to stream without "pauses" the audio. I'm interestend only to the theory. My first idea was capture some bytes every 0,5 seconds to a buffer and then send it to the server, which re-send it to the interested clients. But I don't know how to do this as in-real-time as possible!
Edit Client is Windows and Server is Linux
You would pick a codec and stream based on the clock rate specified by that codec. For example, the G.711 codec specifies a clock rate of 8000 Hz (meaning the microphone input source will be sampled 8000 times per second). It also specifies that (by default) each packet should contain 20 milliseconds of audio, so over one second you would send 50 audio packets (1 second = 1000 millseconds / 20 millseconds per packet = 50 packets per second).
Implementation-wise (for real-time) you would have a separate thread that has "realtime" priority that would be responsible for sampling the audio from the microphone, wrapping it in a RTP packet, and shipping that packet off to your server. Your server would likewise have a separate "realtime" priority thread that would receive each RTP packet and forward it to each client that is subscribed.

How do i connect to a sock4 client's network byte address? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to make a socks 4 proxy server with boost-asio. How can i connect to the site specified by the client if its in network byte order? Can you please provide examples. I'm using a linux so no winsock.
sock4request is what the server receive from the client.
const boost::array<unsigned char,4> addr={sock4request[5],sock4request[6],sock4request[7],sock4request[8]}; //Network byte address
unsigned char port[]={sock4request[3],sock4request[4]};
boost::asio::ip::address_v4 addrip(addr);
unsigned short portint=lexical_cast<unsigned short>(port);
tcp::endpoint addrinfo(addrip,portint);
tcp::socket finalsocket(io_service);
boost::asio::connect(finalsocket,endpoint_iterator);
You should use the built-in linux functions like htons, ntohs..
Please review this page:
http://www.beej.us/guide/bgnet/output/html/multipage/htonsman.html

Programming a motor connected to computer through CAN communication? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have a motor connected to my computer, which is connected through CAN to the motor. Basically, I have a USB-to-CAN adapter, to which I connect a USB cable from my computer. Then, from the adapter, the motor is connected through CAN.
Now, I wish to send data to the motor- I already know what sequence of bytes I need to send, but I'm not sure what commands to use to "talk" to my motor that is connected through CAN. I have been able to send data by direct USB connection from my computer to motor (using the WriteFile command in C++), but this method does not work for CAN.
Are there any libraries/functions that I can use to talk to my motor via CAN in C++?
Since you cannot connect a motor directly to a CAN bus, there must be some sort of motor controller, drive or I/O controller between the bus. Details of this device are required in order to advise on a more than fundamental level.
CAN itself does not define an application layer protocol, and several application protocols exist for CAN, such as CANopen, DeviceNet and SDS. Your device may use such a protocol or possibly something entirely proprietary. Your starting point should be the documentation for your I/O device.
For testing, most PC CAN adapter manufacturers will provide some sort of debug or development tool that allows you to construct and send individual messages and message sequences at a low-level; such a tool will allow you to verify the operation of the bus and I/O device.