datagram

setSotimeout on a datagram socket

时光怂恿深爱的人放手 提交于 2019-12-02 02:40:22
问题 The server acts like an echo server. The clients sends 10 packets to server (1 sec of gap) When Client receives packets from the server, sometimes the packets are lost. So the client has to wait for up to one second for the packet to arrive. If the packet does not arrive in 1 second then the client should continue sending the other packets. How would i use .setSoTimeout to achieve this? Code: import java.io.*; import java.net.*; import java.util.*; /* * Client to process ping requests over

LuaSocket (UDP) not receiving datagrams

孤街醉人 提交于 2019-12-02 01:40:54
I'm experimenting with LuaSocket for a project I'm working on. I've chosen UDP as my protocol. Looking for docs and tutorials online, I've attempted to create a client-server pair for testing and learning. According to what I've read, the following code should work. However, only the server seems to be working properly. The client sends a message, but it will not receive the reply from the server. Thank you for any help anyone can provide. Server: -- Server #!/usr/bin/env lua5.1 local socket = require("socket") udp = socket.udp() udp:setsockname("*", 53474) udp:settimeout(0) while true do data

setSotimeout on a datagram socket

江枫思渺然 提交于 2019-12-02 01:20:40
The server acts like an echo server. The clients sends 10 packets to server (1 sec of gap) When Client receives packets from the server, sometimes the packets are lost. So the client has to wait for up to one second for the packet to arrive. If the packet does not arrive in 1 second then the client should continue sending the other packets. How would i use .setSoTimeout to achieve this? Code: import java.io.*; import java.net.*; import java.util.*; /* * Client to process ping requests over UDP. */ public class PingClient { private static final int AVERAGE_DELAY = 100; // milliseconds public

UWP DatagramSocket Multicast

一世执手 提交于 2019-12-01 22:49:00
I managed to make a simple application that sends and receives data from a multicast group. If I open 2 instance of the application (2 different .sln files with the same code) I can send and receive data. The problem is that after 5 seconds, if I send a message from the Client001 only the Client001 will get the message. But, if I send message from the Client002 (the second instance of the app) within the 5 seconds then both of them get the message. I had an example with UdpClient that was working perfectly, but that is no longer available for UWP. So in conclusion, how can I achieve, no matter

Datagramsocket: how receive(…) handles fragmentation of a packet

扶醉桌前 提交于 2019-12-01 21:14:34
I came to know from my Professor that, a datagram packet sent using UDP socket gets fragmented in the lower layers and may arrive as multiple packets at the receiver end. For e.g, if I send a 1000 bytes data in a datagram packet, at the receiving end it might arrive as, say 2 bytes, 500 bytes, 12 bytes, and so on. Therefore, he suggested to do multiple receive(...) to receive the entire 1000 byte packet sent by the sender. Later when I went through the Java documentation for datagram socket receive(...) and there is a line that reads as follows: "This method blocks until a datagram is received

Packet loss while receiving UDP broadcast in android device

余生颓废 提交于 2019-11-30 20:11:45
For receiving UDP broadcast packets from the server to an android device, i used a service class and listen for packets in a thread. It receives the packet successfully. The problem is that if multiple packets are being sent from the server in the same time then packet loss will be the result. I even tried with a queue and processing the received packets in separate thread then also i am not getting the packet. I am completely new to network programming any help would be widely appreciated void startListenForUdpBroadcast() { UDPBroadcastThread = new Thread(new Runnable() { public void run() {

Some java Datagram Socket questions

99封情书 提交于 2019-11-30 12:24:06
I have recently nose dived into socket programming using java, and I have a few general sort of questions. There is a bind() method, as well as a connect() and disconnect(). There is no unbind(). Is this because upon disconnecting the socket is unbound? Does garbage collection take care of this once the program exits? Or is this not even a valid question? Also, upon creating a DatagramSocket, how is it different if I only provide the port and the address? I am creating a program to collect data off a network, as the data floats around and log it. Should I just use the local address? Could not

Some java Datagram Socket questions

折月煮酒 提交于 2019-11-29 17:36:11
问题 I have recently nose dived into socket programming using java, and I have a few general sort of questions. There is a bind() method, as well as a connect() and disconnect(). There is no unbind(). Is this because upon disconnecting the socket is unbound? Does garbage collection take care of this once the program exits? Or is this not even a valid question? Also, upon creating a DatagramSocket, how is it different if I only provide the port and the address? I am creating a program to collect

Python socket.error: [Errno 13] Permission denied

馋奶兔 提交于 2019-11-29 13:26:47
Using Linux and Python, I want to send some data with broadcast: d = b'109u433279423423423' import socket s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.sendto(d, 0, ('192.168.0.255', 9)) I launch this script under root and get this error: s.sendto(d, 0, ('192.168.0.255', 9)) socket.error: [Errno 13] Permission denied What is wrong? You are trying to send to a broadcast address. It is not allowed, see manpage for sendto(2): EACCES (For UDP sockets) An attempt was made to send to a network/broadcast address as though it was a unicast address. Set the SO_BROADCAST option, if you actually

Whats the difference between a socket which is open and a socket which is connected?

☆樱花仙子☆ 提交于 2019-11-29 09:29:53
The Java Socket class has two methods isClosed and isConnected to check whether the socket is closed or connected respectively. I wanted to know what's the difference between a TCP socket which is only open and a TCP socket which is open and connected, and how is this different from UDP. Russell Gutierrez To put things simply, a Socket that is open is a socket that is either waiting for connection or has successfully connected with another Socket . When a socket has been closed , it means that this socket is no longer available for connection, and that it's resources has already been released.