network-protocols

protobuf-net v2 type meta

落花浮王杯 提交于 2019-11-27 22:51:57
问题 According to this post (from March), protobuf v2 allows us to resolve types from a stream. Since v2 is now in beta 5, I think this feature has already been implemented, so I was wondering how to use this new feature. I haven't been able to find any documentation on it, so some help would be greatly appreciated ! Type meta The serialization is fine, but I don’t know (and cannot know) all of my types up front. How can I do this? Well, protobuf is a contract based format; if you don’t know the

Socket Protocol Fundamentals

喜欢而已 提交于 2019-11-27 22:14:12
问题 Recently, while reading a Socket Programming HOWTO the following section jumped out at me: But if you plan to reuse your socket for further transfers, you need to realize that there is no "EOT" (End of Transfer) on a socket. I repeat: if a socket send or recv returns after handling 0 bytes, the connection has been broken. If the connection has not been broken, you may wait on a recv forever, because the socket will not tell you that there's nothing more to read (for now). Now if you think

Winsock UDP packets being dropped?

北城以北 提交于 2019-11-27 14:01:39
问题 We have a client/server communication system over UDP setup in windows. The problem we are facing is that when the throughput grows, packets are getting dropped. We suspect that this is due to the UDP receive buffer which is continuously being polled causing the buffer to be blocked and dropping any incoming packets. Is it possible that reading this buffer will cause incoming packets to be dropped? If so, what are the options to correct this? The system is written in C. Please let me know if

Get the Default Gateway

蓝咒 提交于 2019-11-27 13:56:11
I'm writing a program that shows the user their IP address, Subnet mask and Default gateway. I can get the first two, but for the last one, this is what I turned up: GatewayIPAddressInformationCollection gwc = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].GetIPProperties().GatewayAddresses; That, of course, returns a collection of GatewayIPAddressInformation . So, if a computer has multiple gateways, how can I determine which is the default gateway? In practice, I've only ever seen this collection contain a single entry, but since it's implemented as a collection,

Understanding struct sockaddr

妖精的绣舞 提交于 2019-11-27 12:59:01
问题 struct sockaddr { unsigned short sa_family; // address family, AF_xxx char sa_data[14]; // 14 bytes of protocol address }; In this structure what exactly is the meaning address family depicted by sa_family ? Does it mean that protocols like TCP/UDP have "addresses"? Well, the protocols can be identification numbers not addresses, I think. Anyway, if yes, then on what basis have their families been divided? 回答1: The format and size of the address is usually protocol specific. sockaddr is used

TCP Hole Punching

蹲街弑〆低调 提交于 2019-11-27 10:02:07
问题 I'm trying to implement TCP hole punching with windows socket using mingw toolchain. I think the process is right but the hole doesn't seems to take. I used this as reference. A and B connect to the server S S sends to A , B 's router IP + the port it used to connect to S S does the same for B A start 2 threads: One thread tries connecting to B 's router with the info sent by S The other thread is waiting for an incoming connection on the same port used to connect to its router when it

Connecting P2P over NAT?

▼魔方 西西 提交于 2019-11-27 09:51:49
问题 I started to explore the option of connecting with other using a p2p connection, so I coded a simple socket program in JAVA for android devices in which the users can share simple messages p2p (I didn't have any idea about NAT then). I got to know about NAT, so I now need to establish a TCP connection with another user which uses a server for discovery but payload is transferred p2p. I have also looked at XMPP(a very good and detailed explanation of how protocol works is here) and UPnP but I

Why is writing a closed TCP socket worse than reading one?

孤者浪人 提交于 2019-11-27 04:25:58
When you read a closed TCP socket you get a regular error, i.e. it either returns 0 indicating EOF or -1 and an error code in errno which can be printed with perror . However, when you write a closed TCP socket the OS sends SIGPIPE to your app which will terminate the app if not caught. Why is writing the closed TCP socket worse than reading it? Robert S. Barnes +1 To Greg Hewgill for leading my thought process in the correct direction to find the answer. The real reason for SIGPIPE in both sockets and pipes is the filter idiom / pattern which applies to typical I/O in Unix systems. Starting

Get the Default Gateway

落爺英雄遲暮 提交于 2019-11-27 04:04:32
问题 I'm writing a program that shows the user their IP address, Subnet mask and Default gateway. I can get the first two, but for the last one, this is what I turned up: GatewayIPAddressInformationCollection gwc = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].GetIPProperties().GatewayAddresses; That, of course, returns a collection of GatewayIPAddressInformation . So, if a computer has multiple gateways, how can I determine which is the default gateway? In practice,

Why is writing a closed TCP socket worse than reading one?

夙愿已清 提交于 2019-11-27 03:58:17
问题 When you read a closed TCP socket you get a regular error, i.e. it either returns 0 indicating EOF or -1 and an error code in errno which can be printed with perror. However, when you write a closed TCP socket the OS sends SIGPIPE to your app which will terminate the app if not caught. Why is writing the closed TCP socket worse than reading it? 回答1: +1 To Greg Hewgill for leading my thought process in the correct direction to find the answer. The real reason for SIGPIPE in both sockets and