I have an application that is being built using Qt. It will be running on machines that will have two (or more) network cards. I need the ability for my application to select which ethernet interfaces for a TCP connection. Before anyone suggests it I cannot guarenteed that routing tables will be setup correctly. I know how to do this using the windows socket classes but have been unable to find anything about it for Qt. Any help would be greatly appreciated!
Are you referring to an outbound connection or an inbound connection?
If you're referring to an inbound connection, all you need to do is specify a QHostAddress to the QTcpServer::listen call.
If you're talking about an outbound connection, you can call QAbstractSocket::setLocalAddress to force the local address to something specific.
Cheers,
If you are using Qt 4.2 or later, you can use QNetworkInterface to get a list of network interfaces in the computer and then create some sort of network interface selection.
Related
I'm currently looking at options to allow me to build a remote COM-port solution.
The idea is to be able to access from my remote PC, another PC that's directly connected to a device locally via its serial COM-port.
I know that the obivous answer is to use a VPN between the 2 Internet connected PCs.
However, I need this solution to be as seamless to the end-user as possible.
i.e. no installing and configuring VPN software, etc.
So I was thinking that WebRTC would be great because the end-user can simply use their web-browser and not have to install any additional software.
My question is, is it possible to stream the COM port data between the 2 PCs via WebRTC?
If so, can you please point me in the right direction as to how I can go about achieving this?
Sorry if this is a ridiculous question, I'm very new to WebRTC, just exploring my options.
Thanks.
That should work great!
Networking wise you get NAT Traversal. That means the two computers can be in completely different networks, and still communicate. You may have to run a TURN server if P2P isn't possible.
Data wise you can exchange anything you want via data channels. It is datagram based and you can send/receive binary data. You get a callback telling you how much has been delivered, that way you can detect backpressure.
Are you ok with installing software on the remote host? You can do something like Pion WebRTC's data-channels. This shows you can have a browser connect to a Go process via WebRTC. Then use tarm/serial on the remote host to interact with the device.
If you want a browser on both ends there is the Web Serial API I haven't used it myself though. That locks you into only doing Chromium which might be an issue.
I've been asked to implement VPN capabilities in an existing software project on an embedded system, in order to make the device available via network to an external server while avoiding trouble with firewalls (no need for encryption, just to make it accessible).
Unfortunately, the embedded system is based on a Cortex-M4 MCU, therefore Linux, which would allow for VPN nearly out of the box, is not an option. All I've got is an RTOS and a working LwIP stack.
I've used VPNs in the past. However, my network knowledge is rather limited concerning implementing VPNs, so I'm rather stumped. As I think, I'd use the current LwIP instance for building up the tunnel connection, and the application would use a second instance for the actual network communication, while the network interface of the second instance is a virtual one (like a tap device on linux), encapsulating its low level data and tranceiving it via the tunnel connection of the first LwIP instance.
Maybe this way I'd be able to create a custom solution for the problem, but the solution should conform to any standards (as the server will be any kind of sophisticated system).
So I wonder if anyone has been confronted with a task like this, and would appreciate any hint what to do, at least a direction where to look at.
Thanks in advance!
Is it possible to connect to a Air app running on another machine via socket(assuming we know ip) or some other mechanism(which doesnt use Cirrus/stratus)? If it is can someone please help me on how?
Let me rephrase question, I dont want to connect to a server over socket. I would like to know if it is possible to connect from one AIR app on machine A to connect to another AIR app on machine B via sockets without cirrus. I'm not asking for someone else to do my work, I couldnt find any documentation or possibility of the above thing. My conclusion now is that it is not possible, but I would just like it to be verified by other people(experts).
Absolutely, as3 supports sockets. http://www.ultrashock.com/forum/viewthread/81676/
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/Socket.html?filter_flash=cs5&filter_flashplayer=10.2&filter_air=2.6
There are two ways to do it. One AIR app can act as a server by creating a ServerSocket object while the other app connects to this with the Socket class. The other way is to use the DatagramSocket class.
In both cases, the trick is that because of network access translation, the IP address to use is not always easily discoverable unless at least one of the computers has a static IP. If both computers are on the same network subnet you can look up the IP address needed to reach one computer from the other manually. Otherwise, the IP one computer must use to reach the other won't be the same IP that the computer sees for itself. This matchmaking is the service that stratus/cirrus provides.
See http://www.brynosaurus.com/pub/net/p2pnat/ for a description of the problem.
My app needs to access two network cards. One to receive data (eth0) and another to send data (3G modem).
Normally, the kernel force the app to work with only one card at a time.
Is there any thing that I can do to make it run?
Thank you.
The kernel does no such thing.
The kernel will route your traffic to the most appropriate end destination based upon the routing information and networks each card is assigned. However, if you are using TCP, your bidirectional communication will use only one route as there is only one address associated with that connection.
If you are trying to implement an multi-homing send/receive system, this is not supported in normal TCP - you will need to use a different protocol, likely implemented in the kernel.
The kernel is not forcing you to use a single interface. It just chooses a default interface if you don't specify otherwise. You can specify a specific interface by specifying it's IP address in the bind() command. To get a list of the available interfaces and their names, use the ioctl(SIOCGIFCONF) function.
Here's an example: http://techpulp.com/2008/10/get-list-of-interfaces-using-siocgifconf-ioctl/
You can make two different UDP sockets bind to separate NICs with the bind(2) and send on one and listen on the other.
I'm trying to create an application to craft packets to be able to debug some gateways here, and to experiment with TCP DoS situations.
Nevertheless this should be very easy, I didn't find a way to implement this for a Windows application.
I started using Impacket from Core Security in Python on a Unix box, but I want to avoid this for now. First of all Impacket doesn't work for Windows, and it doesn't seem to do exactly what I want.
Does anyone know how to get a simple raw-socket like behavior in Windows? I know that there're no Raw sockets any more. But is there something similar? Any C# library I can use... I didn't find anything jet.
Thanks ;)
There's not a lot to creating the socket.
using System.Net.Sockets;
Socket rawSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Raw);
or if it's custom TCP packets you're after:
Socket rawSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
If you're planning on sending IP or higher layer packets that's not exposed by the .Net framework. However IP and TCP packets are pretty simple to put together and if you're testing malformed packets you'll most likely need to customise the packets anyway.
Try to use libpcap (winpcap), it can work under the tcp/ip stack, just on raw packet level.