network-programming

UDP Broadcast in Windows 7 - does it work?

本小妞迷上赌 提交于 2019-12-29 06:26:29
问题 I'm trying to write some code under Windows 7 to broadcast across my local network and can't get the following code to work. I come from a Linux background so apologies for style - the full code compiles etc and works and if I use an address of: unsigned long broadcastAddr = inet_addr("192.168.10.0") | ~(inet_addr("255.255.240.0")); Then that works fine, I just would really like to use the preferred INADDR_BROADCAST/255.255.255.255 method. <snip> SOCKET sockfd; int broadcast = 1; WSADATA

setting limit on concurrent tasks in AFNetworking 2 running AFHTTPSessionManager

一个人想着一个人 提交于 2019-12-29 03:18:25
问题 so I know that in the old AFNetworking this was possible using the AFHTTPClient, and I know that if I use AFHTTPRequestOperationManager I can set the queue's limit, but I can't make AFHTTPSessionManager to run only x requests at a time without implementing it by myself using the success block (which I don't want to). The following code did NOT limit my connections: AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.operationQueue.maxConcurrentOperationCount = 1; In line

What is the Difference Between read() and recv() , and Between send() and write()?

会有一股神秘感。 提交于 2019-12-29 02:21:07
问题 What is the difference between read() and recv() , and between send() and write() in socket programming in terms of performances, speed and other behaviors? 回答1: The difference is that recv() / send() work only on socket descriptors and let you specify certain options for the actual operation. Those functions are slightly more specialized (for instance, you can set a flag to ignore SIGPIPE , or to send out-of-band messages...). Functions read() / write() are the universal file descriptor

Network bridge using Scapy and Python

女生的网名这么多〃 提交于 2019-12-28 18:13:18
问题 I am creating a network bridge that connects two ethernet cards on the same machine. One of the cards is connected to the LAN and the other is connected to a network device. It looks something like this, I am sniffing packets on both the interfaces and then sending them to the other using sendp(x,iface='eth0') for a packet that I sniffed on eth1 and vice versa. I verified the packets at both the interfaces and found them to be correct, but somehow I am unable to get an IP for the device.

Android - find a server in the network

坚强是说给别人听的谎言 提交于 2019-12-28 08:39:07
问题 I am currently writing a client-server application and I ask myself if there is a better way to find a server in the local network then going trough all the available IP addresses and see if the correct answer is supplied? 回答1: You might want to look into UDP broadcasts, where your server announces itself and the phone listens for the broadcasts. There is an example from the Boxee remote project, quoted below. Getting the Broadcast Address You need to access the wifi manager to get the DHCP

TCP Socket no connection timeout

对着背影说爱祢 提交于 2019-12-28 07:59:15
问题 I open a TCP socket and connect it to another socket somewhere else on the network. I can then successfully send and receive data. I have a timer that sends something to the socket every second. I then rudely interrupt the connection by forcibly losing the connection (pulling out the Ethernet cable in this case). My socket is still reporting that it is successfully writing data out every second. This continues for approximately 1hour and 30 minutes, where a write error is eventually given.

Sending and receiving files on socket

只谈情不闲聊 提交于 2019-12-28 03:14:09
问题 I am sending files to remote Android client from java server. I write the bytes using outputstream. On reading these bytes read() method keep trying to read bytes after the stream is ended. if I close the outputstream on server-side, read operation work fines. But I have to write file on the same socket again so can't close output stream any solution? NOTE: MY CODE WORKS FINE FOR SHARING SINGLE FILE CODE FOR WRITING FILE public static void writefile(String IP, String filepath, int port,

C# An established connection was aborted by the software in your host machine

大城市里の小女人 提交于 2019-12-27 23:40:55
问题 These errors are getting more and more frequent on my Game Server. They are causing the server to keep closing and restarting... System.Net.Sockets.SocketException (0x80004005): An established connection was aborted by the software in your host machine at System.Net.Sockets.Socket.BeginSend(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state) at iRP.Game.Sessions.Session.SendData(Byte[] Data) This is the code from which these errors are

How send raw ethernet packet with C#? [closed]

半腔热情 提交于 2019-12-27 20:07:09
问题 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 10 months ago . Is there a way to send raw packet Ethernet to other host via C#? In Windows 7 if it makes difference. 回答1: Based on suggestion by Saint_pl: I found probably better solution - similar to SharpPcap. It's Pcap.Net - .NET wrapper for WinPcap. Now I can modify my packets whatever I

How to get IP of all hosts in LAN?

♀尐吖头ヾ 提交于 2019-12-27 19:12:40
问题 I need to list IP addresses of all connected hosts in my LAN. What is the simplest way to do this? 回答1: You'll have to do a ping sweep. There's a Ping class in the System.Net namespace. Example follows. Also this is only possible if your computers don't have firewalls running. If they've got a firewall enabled, there's no way to determine this information short of doing SNMP queries on your switches. System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping(); System.Net