network-programming

Is epoll thread-safe?

試著忘記壹切 提交于 2020-04-05 07:32:05
问题 There are two functions in epoll: epoll_ctl epoll_wait Are they thread-safe when I use the same epoll_fd? What will happen if one thread calls epoll_wait and others call epoll_ctl at the same time? 回答1: It is thread-safe, but there isn't much documentation that explicitly states that - see http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-03/msg00084.html BTW, you can also have multiple threads waiting on a single epoll_fd, but in that case it can get a bit tricky (i.e. you might want to

Is urgent tcp data acknowledged?

落爺英雄遲暮 提交于 2020-03-21 20:55:51
问题 In a tcp segment with the URG flag up there might be normal data as well. How does the receiving host handles the urgent packet? How does it acknowledge the urgent data if it is not part of the data stream? Does it acknowledge the rest of it? I understand that it is not usually used, but if both hosts support the same RFC about the URG flag, how do they handle out-of-band data? If the urgent data is an abort message, the receiver will drop all other data, but the sender will still want an

unable to receive UDP broadcast in Xamarin.Forms app

独自空忆成欢 提交于 2020-03-21 07:01:49
问题 I created a test Xamarin.Forms project, tabbed app, with support for iOS, Android, and UWP. The app with the boilerplate starter code builds and and runs correctly on all 3 platforms. Am trying to test receiving UDP broadcast in the app . The UDP broadcast is being sent from another machine on the same subnet (have tested broadcasting from another machine and from the same machine, results are the same). If I run a standalone, unmanaged UDP listener test tool on this machine (one we wrote

Bonjour: Search for a service by name

£可爱£侵袭症+ 提交于 2020-03-06 04:50:13
问题 I have an application that needs to search and resolve a Bonjour-advertised service whose name is known in advance. Most Bonjour examples I have found related to service discovery are structured more or less like this: Call browse to detect all services of a given type (for example, this could be _http._tcp ) For each service found, serviceFound is called. Service names are reported here Call resolve on each service found For each service resolved, serviceResolved is called Is it possible

What happens when I execute several fetch at the same time?

无人久伴 提交于 2020-03-05 01:37:28
问题 What happens when I execute several fetch at the same time? Does each fetch run completely separately and one fetch doesn't have to wait for another to finish? Or are all the fetch somehow "linked"? Let us take a concrete example: - I execute two fetch at the same time, one that calls an API and asks to retrieve information and the other one that calls another API but this one has a 'long response time' (so the fetch will run for a long time). Can the second fetch influence the response time

Twisted with multiple ports, protocols, and reactors

与世无争的帅哥 提交于 2020-02-24 21:16:35
问题 Will twisted support listening on multiple ports, with different 'handlers' (different set of callbacks for each port) at the same time? Essentially, I want my process to host two servers in one process, each performing a different function. Would I need to use two reactors to do this? 回答1: Yes, for instance, modifying the quote server example you could add a second instance listening on a different port with a different quote: from twisted.internet.protocol import Factory, Protocol from

Asynchronous tasks. Which architecture? (Or pattern in zeroMQ)

霸气de小男生 提交于 2020-02-22 05:48:28
问题 I want one application on a Linux(Server) host to communicate with applications on Win7(Client) in a VM. Lib of choice is ZeroMQ. But how do I manage asynchronous tasks? Let me give an example: The application in the VM generates tasks in arbitrary intervals and sends them to the Linux box. This will process them but needs some time to answer. In this time the socket in REQ/REP pattern is blocked and incoming tasks from the WinApp can not be forwarded to the LinuxApp. How should I solve this?

Chat Server: Print chat history java

本秂侑毒 提交于 2020-02-08 09:38:44
问题 The problem is that I need to show chat history on the client side without transferring the chat file. The server and the client are on the same machine ie my pc. The server reads char by char from file and writes it on the socket. The client needs to read it as string to get exact chat history as saved in file. But by my method it is printing single char in single line import java.io.*; class Server { public static void main(String dt[]) { ServerSocket sskt=null;Socket skt=null;

Chat Server: Print chat history java

China☆狼群 提交于 2020-02-08 09:37:10
问题 The problem is that I need to show chat history on the client side without transferring the chat file. The server and the client are on the same machine ie my pc. The server reads char by char from file and writes it on the socket. The client needs to read it as string to get exact chat history as saved in file. But by my method it is printing single char in single line import java.io.*; class Server { public static void main(String dt[]) { ServerSocket sskt=null;Socket skt=null;

how to determine interface name

无人久伴 提交于 2020-02-06 04:23:19
问题 I have some code that sends tcp package with SOCK_RAW socket. My program takes a single parameter: the name of the host Here is a description of how the program works: getaddrinfo(argv[1], NULL, hints, &answ) //argv[1] it is host name .... .... socket(tmp->ai_family, tmp->ai_socktype, tmp->ai_protocol) //tmp = answ->ai_next .... .... /* filling the tcphdr struct */ send_frame->source = s_port; send_frame->dest = d_port; send_frame->seq = seq_num; send_frame->ack_seq = ack_num; send_frame-