network-programming

How to restart NWListener once it was cancelled?

只愿长相守 提交于 2021-01-28 11:52:06
问题 I would like to receive some data via UDP in an endless loop until the user cancels the data receiving. I created an NWListener , and set it up. It receives data as expected. However once I call .cancel() on my NWListener it changes the state to .cancelled but afterwards I have no chance to restart the listening process again. It blocks somehow the port. I would be able to restart it on another port, but this is not what I want to do. On the same port it ends up in this error message: 2020-02

Select() + UDP resulting in too many open files

这一生的挚爱 提交于 2021-01-28 05:06:07
问题 I currently have a select() statement configured to keep track of two UDP sockers. I send perhaps 10 - 20 messages a second at one general data socket, which is this interpreted as I expected. However, once I hit around 1024 messages, I get the notice: talker: socket: Too many open files talker: failed to bind socket This is logical to me, since ulimit -n shows a max of 1024 open files for this user. However, why are there all of these open files? With UDP, there is no connection made, so I

How to use/include the QtNetwork Module

▼魔方 西西 提交于 2021-01-27 14:53:05
问题 I'm trying to develop a simple application in C++ that sends Files between two computers over LAN. After some research i found out that the QtNetwork Module is the way to go. I do include the QTcpServer and QTcpSocket in my solution. #include <QTcpServer> #include <QTcpSocket> I added the following path to the Additional Include Directories of my project. C:\Qt\5.14.2\msvc2017_64\include\QtNetwork I then tried a very simple Code. QTcpSocket* pTcpSocket = new QTcpSocket(); I get the

Windows service: Listening on socket while running as LocalSystem

和自甴很熟 提交于 2021-01-27 13:14:40
问题 I'm writing a small server-like program in C for Windows (using MinGW/GCC, testing on Windows 7) which is eventually supposed to run as a service with the LocalSystem account. I am creating a socket, and using Windows Sockets bind() , listen() and accept() to listen for incoming connections. If I run the application from the command line (i.e. not as a service, but as a normal user), I have no problems connecting to it from external IPs. However, if I run the program as a service with the

How to Get uid from packet - android

两盒软妹~` 提交于 2021-01-27 06:50:49
问题 I am developing a firewall application in android where I need to identify apps based on uid. I have created a vpn service and I am able to capture packets and get destination ip address. Is there any way to get uid of apps from packets or datagram sockets. 回答1: Parse the packet, for TCP/UDP, you can retrieve the (local_ip, local_port, remote_ip, remote_port) tuple. Then read and parse /proc/net/tcp or /proc/net/udp, there's uid field in it. This is a loopback socket whose owner uid is 10117:

Can you connect an HTML5 web socket to a Java Socket?

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-27 02:25:56
问题 I had set up a system that had a Java program running on a server and a Java applet embedded in a page on a client's browser and the two communicating via Java sockets. I'm wondering if I can switch over from a Java applet to just HTML5 and javascript, using a WebSocket on the client side for communication with the Java socket on the server. Is there a simple way to make a WebSocket communicate with a Java Socket? 回答1: Is there a simple way to make a WebSocket communicate with a Java Socket?

Can you connect an HTML5 web socket to a Java Socket?

≯℡__Kan透↙ 提交于 2021-01-27 02:24:33
问题 I had set up a system that had a Java program running on a server and a Java applet embedded in a page on a client's browser and the two communicating via Java sockets. I'm wondering if I can switch over from a Java applet to just HTML5 and javascript, using a WebSocket on the client side for communication with the Java socket on the server. Is there a simple way to make a WebSocket communicate with a Java Socket? 回答1: Is there a simple way to make a WebSocket communicate with a Java Socket?

Can you connect an HTML5 web socket to a Java Socket?

混江龙づ霸主 提交于 2021-01-27 02:23:25
问题 I had set up a system that had a Java program running on a server and a Java applet embedded in a page on a client's browser and the two communicating via Java sockets. I'm wondering if I can switch over from a Java applet to just HTML5 and javascript, using a WebSocket on the client side for communication with the Java socket on the server. Is there a simple way to make a WebSocket communicate with a Java Socket? 回答1: Is there a simple way to make a WebSocket communicate with a Java Socket?

How to slow down a service-worker to simulate 56k or 2G 3G slow connection

ε祈祈猫儿з 提交于 2021-01-20 07:53:25
问题 Here is my use-case : I'me developping Static Site Generator and stuff for them. I would like to host on static pages (like gitlab-pages or github-pages) some demo of my stuff. So I can't use server-side tricks to simulate slow connexion. My demo page should look like this : see my stuff in normal mode see my stuff before optimisation with a simulated 56k connection see my stuff after optimisation with a simulated 56k connection I've not found any service-worker built for this. Any Idea where

Is Serialization the best for sending data over a socket?

邮差的信 提交于 2021-01-05 06:19:23
问题 Someone told me That Serialization was not the best way to send things over a socket but they said they read that in a book once and was not sure of a better way cause they haven't really done networking before. so is Serialization the best way or is there a better way. Also this is for a game if that makes much of a difference. What i see by searching questions about sending objects over it looks like most people use Serialization but im just checking to see what people thing 回答1: To