network-programming

TCP Client-Server “bad address” error (in C)

試著忘記壹切 提交于 2020-01-03 01:42:09
问题 Although it seems to be correctly implemented, it keeps on returning me ERROR when I establish a connection using the loopback address (127.0.0.1). In addition to a simple TCP Client/Server connection, I have added an additional case: If the client tries to send data but finds the connection closed , it is closed too. I perform it by checking if received data is equal to 0 (recv) . Given error : CLIENT: Welcome to the Client mode Please, enter the Server's IP Address and Port (eg. 192.128.192

File Descriptor Sharing between Parent and Pre-forked Children

落花浮王杯 提交于 2020-01-03 01:40:11
问题 In Unix Network Programming there is an example of a Pre-forked server which uses message passing on a Unix Domain Pipe to instruct child processes to handle an incoming connection: for ( ; ; ) { rset = masterset; if (navail <= 0) FD_CLR(listenfd, &rset); /* turn off if no available children */ nsel = Select(maxfd + 1, &rset, NULL, NULL, NULL); /* 4check for new connections */ if (FD_ISSET(listenfd, &rset)) { clilen = addrlen; connfd = Accept(listenfd, cliaddr, &clilen); for (i = 0; i <

IO Completion Ports and socket WSARecv()

岁酱吖の 提交于 2020-01-02 22:00:15
问题 I am trying to understand how IOCP works with sockets. I need to understand if this is how they work: I create a completion port, which is nothing but a queue that will receive notifications when some operation completes, and then I associate my socket with it, and then I process incoming notifications. Now I want to know how this relates to receiving of data from a socket, so when I call WSARecv() what exactly happens, does WSARecv() returns immediately when I call it (does not block) and

Qt Stream IP Camera Video

我与影子孤独终老i 提交于 2020-01-02 18:06:49
问题 I am trying to stream the video from an IP camera using Qt multimedia (Qt 5). A similar question could be found here: Play a Live video Stream using Qt but I try to avoid using an other library such as LibVLC. I manage to display the video from a locally stored file but not to display the stream from the IP camera. Here is my code: #include "mainwindow.h" #include "ui_mainwindow.h" #include <QMediaPlayer> #include <qvideowidget.h> #include <QVideoWidget> #include <QDebug> MainWindow:

Linux: How to send a whole packet to a specific port on another host?

有些话、适合烂在心里 提交于 2020-01-02 09:19:07
问题 I have captured a TCP packet using libpcap, and I want to send this whole packet(without modifying it) to a specific port on another host(which has another sniffer listening to that port). Is there any way I can do this? Thanks a lot! 回答1: You didn't specify which programming language you're using and what you've tried so far. Change the IP address field to the target IP and the TCP port field to the port you want. Don't forget to update both checksums. If what you want is TCP forwarding, the

How to determine IP used by client connecting to INADDR_ANY listener socket in C

馋奶兔 提交于 2020-01-02 08:06:13
问题 I have a network server application written in C, the listener is bound using INADDR_ANY so it can accept connections via any of the IP addresses of the host on which it is installed. I need to determine which of the server's IP addresses the client used when establishing its connection - actually I just need to know whether they connected via the loopback address 127.0.0.1 or not. Partial code sample as follows (I can post the whole thing if it helps): static struct sockaddr_in serverAddress

How to determine IP used by client connecting to INADDR_ANY listener socket in C

一个人想着一个人 提交于 2020-01-02 08:06:06
问题 I have a network server application written in C, the listener is bound using INADDR_ANY so it can accept connections via any of the IP addresses of the host on which it is installed. I need to determine which of the server's IP addresses the client used when establishing its connection - actually I just need to know whether they connected via the loopback address 127.0.0.1 or not. Partial code sample as follows (I can post the whole thing if it helps): static struct sockaddr_in serverAddress

Android volley, how to pass post parameters dynamically

半城伤御伤魂 提交于 2020-01-02 06:21:09
问题 I'm new to google's Volley network library (and also to Android !), and I'm trying to pass POST arguments in a dynamic way ! For now I am overiding the : getParams() method : And returning the params in an hard coded manner. @Override protected Map<String, String> getParams() { Map<String, String> params = new HashMap<String, String>(); params.put("login", "my_login"); params.put("password", "my_password"); return params; } I would like to pass variables instead of "hard coded" strings...

Hitting Java web service: curl or URLConnection

…衆ロ難τιáo~ 提交于 2020-01-02 05:28:41
问题 I am using a Java server that exposes a RESTful API on the following URL: http://localhost:8080/my-server/ The docs recommend using curl for submitting simple PUT requests (file uploads), and strongly recommend users to use the exact same arguments as provided in the examples. All of the examples look like this: curl -X PUT -f -u admin:password --data-binary @/absolute/path/file/to/upload/file.ext "http://localhost:8080/my-server/file.ext" This server will not work with FTP or any other

Get a remote MAC address via IPv6

允我心安 提交于 2020-01-02 04:19:06
问题 Is it possible to get the MAC from an another PC in the same Network via IPv6 (without WMI)? With IPv4 it is easy (ARP). IPv6 uses the "Neighbor Discovery Protocol" (NDP) to get the MAC address. Are there any methods in .Net for this? 回答1: You can run the external command "netsh int ipv6 show neigh", and filter out the host you are interested in. You should have contacted it just before that, so you know it is in the NC. If you want an API for that, use GetIpNetTable2 or, more directly,