network-protocols

Read from socket: Is it guaranteed to at least get x bytes?

孤街浪徒 提交于 2019-12-01 18:03:44
问题 I have a rare bug that seems to occur reading a socket. It seems, that during reading of data sometimes I get only 1-3 bytes of a data package that is bigger than this. As I learned from pipe-programming, there I always get at least 512 bytes as long as the sender provides enough data. Also my sender does at least transmit >= 4 Bytes anytime it does transmit anything -- so I was thinking that at least 4 bytes will be received at once in the beginning (!!) of the transmission. In 99.9% of all

In protocol design, why would you ever use 2 ports?

牧云@^-^@ 提交于 2019-12-01 15:38:47
When a TCP Server does a socket accept on a port, it gets a new socket to work with that Client. The accepting socket remains valid for that port and can accept further clients on that port. Why did the original FTP specification RFC 959 decide to create both a control port and a data port? Would there be any reason to do this in a similar custom protocol? It seems to me that this could have been easily specified on a single port. Given all the problems with firewalls and NATS with FTP, it seems that a single port would have been much better. For a general protocol implementation, the only

Get Wi-Fi protocol (802.11a/b/g/n) programmatically

…衆ロ難τιáo~ 提交于 2019-12-01 15:00:58
Through WifiManager, my Android app can get a lot of details about Wi-Fi. However I fail to get protocol type like a/b/g/n. I have a client requirement to do that. Does anyone know how to achieve that? (I don't have the option to use adb). It is to be done programmatically. I strongly believe that device and router have already negotiated protocol before they can connect. So that information is there with device. Question is, how do we get it? You can partially deduce the protocol from the link speed WifiManager.getConnectionInfo().getLinkSpeed() By Wikipedia 802.11 protocols speed table you

Get Wi-Fi protocol (802.11a/b/g/n) programmatically

笑着哭i 提交于 2019-12-01 13:50:45
问题 Through WifiManager, my Android app can get a lot of details about Wi-Fi. However I fail to get protocol type like a/b/g/n. I have a client requirement to do that. Does anyone know how to achieve that? (I don't have the option to use adb). It is to be done programmatically. I strongly believe that device and router have already negotiated protocol before they can connect. So that information is there with device. Question is, how do we get it? 回答1: You can partially deduce the protocol from

How do I collect bandwidth utilization data on remote devices/switches/servers?

我是研究僧i 提交于 2019-12-01 10:46:16
How do I collect bandwidth usage/utilzation on devices/switches. From what I understand there are systems that do something like this. They seem to all have snmp in common. I am looking for imformation on possibly rolling my own system for collecting this data that will be later used on a web-based front-end. For a real-world but perhaps a bit over complicated example of what I'm talking about take a look at ubersmith de . Most of it will be in a LAMP environment. Thanks. On pure SNMP point of view, there is a Management Information Base (MIB) on your SNMP device. This base is a kind of tree

how to (simply) generate POST http request from java to do the file upload

房东的猫 提交于 2019-12-01 08:09:59
I would like to upload files from java application/applet using POST http event. I would like to avoid to use any library not included in SE, unless there is no other (feasible) option. So far I come up only with very simple solution. - Create String (Buffer) and fill it with compatible header ( http://www.ietf.org/rfc/rfc1867.txt ) - Open connection to server URL.openConnection() and write content of this file to OutputStream. I also need to manually convert binary file into POST event. I hope there is some better, simpler way to do this? You need to use the java.net.URL and java.net

how to (simply) generate POST http request from java to do the file upload

隐身守侯 提交于 2019-12-01 07:03:32
问题 I would like to upload files from java application/applet using POST http event. I would like to avoid to use any library not included in SE, unless there is no other (feasible) option. So far I come up only with very simple solution. - Create String (Buffer) and fill it with compatible header (http://www.ietf.org/rfc/rfc1867.txt) - Open connection to server URL.openConnection() and write content of this file to OutputStream. I also need to manually convert binary file into POST event. I hope

XmlSerializer.Deserialize blocks over NetworkStream

喜欢而已 提交于 2019-12-01 06:35:05
I'm trying to sends XML serializable objects over a network stream. I've already used this on an UDP broadcast server, where it receive UDP messages from the local network. Here a snippet of the server side: while (mServiceStopFlag == false) { if (mSocket.Available > 0) { IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, DiscoveryPort); byte[] bData; // Receive discovery message bData = mSocket.Receive(ref ipEndPoint); // Handle discovery message HandleDiscoveryMessage(ipEndPoint.Address, bData); ... Instead this is the client side: IPEndPoint ipEndPoint = new IPEndPoint(IPAddress

XmlSerializer.Deserialize blocks over NetworkStream

一世执手 提交于 2019-12-01 05:18:22
问题 I'm trying to sends XML serializable objects over a network stream. I've already used this on an UDP broadcast server, where it receive UDP messages from the local network. Here a snippet of the server side: while (mServiceStopFlag == false) { if (mSocket.Available > 0) { IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, DiscoveryPort); byte[] bData; // Receive discovery message bData = mSocket.Receive(ref ipEndPoint); // Handle discovery message HandleDiscoveryMessage(ipEndPoint.Address,

Processing packets with unknown IPv6 extension headers

帅比萌擦擦* 提交于 2019-11-30 20:08:30
Question Should one discard a packet with an unknown IPv6 extension header? Details I could not find an answer to this question by examining the RFC . The book IPv6 Essentials states on page 22: If a node is required the next header but cannot identify the value in the Next Header field, it is required to discard the packet and send an ICMPv6 Parameter Problem message back to the source of the packet. I read this as: a IPv6 packet with a custom extension header cannot will be dropped unless all IPv6 stacks along the path know how to deal with the header. Or equivalently, if a single IPv6