datagram

UPD packets doesn't arrive on a Samsung Galaxy Tab 7.7 but they arrive on a HTC Desire

断了今生、忘了曾经 提交于 2019-12-11 07:09:57
问题 I'm developing an Android 3.1 Tablet application. I'm going to use this app to listen to UDP packets send by a device which is sending UDP packets to 255.255.255.255:8001 every 5 seconds. Using desktop program Docklight scripting v1.9 I see that this device sends a 11 bytes packet every 5 seconds, by my app doesn't receive every packet: sometimes it receives one, and sometimes it receives 5 or 6 packets at the same time. This is my Activity: public class UDPSocketActivity extends Activity {

What's the diffrence between DatagramPacket.getData().length and DatagramPacket.getLength() in java

空扰寡人 提交于 2019-12-11 01:55:21
问题 In the code segment below, DatagramPacket rPacket rPacket = new DatagramPacket(new byte[2000], 2000); .. do some socket.receive .. what would be the difference between DatagramPacket.getData().length and DatagramPacket.getLength() in java 回答1: The difference is that the first returns the size of the array used to construct the object, which never changes; the second returns the smaller of the length supplied to the constructor and the actual length of the smallest datagram most recently

Java byte to string

て烟熏妆下的殇ゞ 提交于 2019-12-10 11:33:31
问题 So I want to convert a byte array returned by the DatagramPacket's getData() function into a string. I know the way to convert the whole byte array to string is just: String str = new String(bytes); However, this prints out null characters at the end. So if the byte array was [114, 101, 113, 117, 101, 115, 116, 0, 0, 0] The 0's print out empty boxes on the console. So I basically only want to print out: [114, 101, 113, 117, 101, 115, 116] So I made this function: public void print

Spoof source IP/Port with DatagramPacket

浪子不回头ぞ 提交于 2019-12-10 11:25:19
问题 Is there any way to spoof the source IP/Port of a DatagramPacket object in Java? 回答1: Raw Socket is a term that'll help your search. You can look at the following question: Best way to do RAW socket programming involving Java They recommend a raw-socket wrapper, rocksaw. 来源: https://stackoverflow.com/questions/10626262/spoof-source-ip-port-with-datagrampacket

Are datagrams always received completely?

余生长醉 提交于 2019-12-08 14:54:08
问题 Most datagram receiving functions such as c's recv or read, javas DatagramPacket class or pythons SocketServer, include the possibility to find out the amount of received data. c: int amount = recv(sock, buf, n, MSG_WAITALL); java: int amount = datagramSocket.getLength(); python: class MyUDPHandler(socketserver.BaseRequestHandler): def handle(self): amount = len (self.request[0]) Are these reliable? Or is it possible that only parts of the message are received, due to for example packet

Sending DNS query to a domain in Android

僤鯓⒐⒋嵵緔 提交于 2019-12-08 12:26:41
问题 I am trying to send a DNS query message to let's say www.google.com to get A record of DNS. I read this article to find out the structure of DNS query. I created the buffer message as: private static final byte[] RequestPacket = { // Transaction ID: 0x0000 0x00, 0x00, // Flags: 0x0000 (Standard query) 0x00, 0x00, // Questions: 1 0x00, 0x01, // Answer RRs: 0 0x00, 0x00, // Authority RRs: 0 0x00, 0x00, // Additional RRs: 0 0x00, 0x00, // Queries // Name: www.google.com 0x03, 0x77, 0x77, 0x77,

Send and receive in UDP from server and client in C

你说的曾经没有我的故事 提交于 2019-12-08 06:01:19
问题 I am trying to implement a server and a client that both send and receive (in different order) a datagram. I am trying on the following way but the datagram from client is not sent/received. Here the client: #include <sys/socket.h> #include<netdb.h> #include <netinet/in.h> #include <stdio.h> #define DATA "Este es el mensaje ...." int main(int argc, char *argv[]) { int sock, lon2; struct sockaddr_in name, name2; struct hostent *hp; char buf[1024]; sock=socket(PF_INET,SOCK_DGRAM,0); if (sock<0)

Stream from Android device to shoutcast (upstreaming)

喜你入骨 提交于 2019-12-08 04:13:44
问题 Thanks to all of you in advance :) I want to make it clear before you start reading that I want to develop an android based app to use android device as a broadcaster, which records sound using its mic and sent it to shoutcast server something like this: Android Device with internet connection -> Shoutcast Server -> listeners. So please do not get confused with playing shoutcast streams on android, because I do not want to develop a player to play an stream. If you are looking for developing

how can I send raw packets over wifi without a network?

∥☆過路亽.° 提交于 2019-12-07 17:04:18
问题 I am trying to send some data between 2 raspberry pi's over wifi without them being connected to a network. I want it to work similar to the way beacons and probe requests work, where a broadcast can be sent out the wireless interface. the data I want to send will be the hostname of the device and the time the packet was sent. I've been trying to figure this out for the last few days but I cannot get anything to work without them being on the same network. Is anybody able to point me in the

Using QUdpSocket to send datagrams

寵の児 提交于 2019-12-07 13:59:38
问题 I am trying to send a datagram using QUdpSocket. The following is the code I am using: udpSocket = new QUdpSocket(this); QByteArray datagram = "Message"; udpSocket->writeDatagram(datagram.data(), datagram.size(), QHostAddress::Broadcast, 45454); Now if I run this on a computer that has only one network adapter, it seems to work with no problem. However, if there are multiple adapters, I need to be able to control which is used to send the datagram. I have found that if I bind the socket as