Urgent Datagram Socket

hi to All,
I am facing some problem when i am broadcasting a data packet by using the datagram socket in java
I am using the IP Address 255.255.255.255 to broadcast a packet . The Packet is send , but the programs goes in Indefinite till when receiving a Message from the Machines that are connected in the Local Network !!!!!!!!!!!
Actually , i wana to collect all the Machines IP Address by sending a Broadcast Packet(by using UDP) . Can i body tell whts the Solution of this probelm , so that i retrieve the IP Address of the Machines that are connected in a local Network

" You can only do it if you know that all machines will respond to an udp package on some port."
HI
I am having trouble in broadcasting the data on 255.255.255.255 at port 3988.
Can you people send me the code for -
How to broadcast the data on 255.255.255.255 at port 3988 ??
and
How it can be received by any client machine at its port 3988 and How client can come to know from where the data is coming i.e. from which machine the data is coming.
As you have told that it is possible if we know the port "You can only do it if you know that all machines will respond to an udp package on some port.", the port is 3988.
Thanks & Regards
Abhishek

Similar Messages

  • Datagram socket and security manager

    I have subclassed the security manager to implement my own network security rules.
    However when the receive(datagramPacket) method is called by the my datagram socket, the host parameter passed to the checkAccept(host, port) method does not belong to the sender of the packet(to be received).
    How then can malicious addresses be blocked by the security manager, as suggested by the comments in the source code of DatagramSocket.
    Any help is greatly appreciated. Thank you in advance.

    However when the receive(datagramPacket) method is
    called by the my datagram socket, the host parameter
    passed to the checkAccept(host, port) method does
    not belong to the sender of the packet(to be
    received).It should. What are you getting instead?

  • Datagram Socket  send different sizes Buffers ...

    hi,
    I'm sending different sizes Datagrams from a datagram socket
    so how can I receive them
    I've tried to send the packet in two packets the first one is fixed size that carries the size of the real data then create a suitable buffer on the client side to receive the second packet but the result is very slow ...
    I'd like to know any suggestions about how to do this properly
    to reach a stream like synchronization between the client and the server ..
    thanks in advance

    use a receive buffer large enough for the largest package possible on your network. Typically, this is 1500 data bytes, but it depends on the network technology. If you want to be sure, allocate a 65536 bytes buffer, which will fit for any technology. But typically, 1550 will fit in a LAN.

  • Datagram socket is not working

    Hi,
    I made a datagram socket and try to send a byte array. but when I called socket.send method it returned an error that an operation is attempted on invalid socket. What I am missing
    here is my code...
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="480" height="262">
    <mx:Script><![CDATA[
    private var udp:DatagramSocket = new DatagramSocket();
    private var address:String = "255.255.255.255";
    private var port:uint = 200;
    private function OnSend():void
      udp.addEventListener(DatagramSocketDataEvent.DATA, RecvUdpDataHandler);
      var byteArray:ByteArray = new ByteArray();
      byteArray.endian = Endian.LITTLE_ENDIAN;
      byteArray.writeMultiByte("dvcrNetshare", "US-ASCII");
      byteArray.writeUnsignedInt(123);
      udp.send(byteArray, 0, byteArray.length, address, port);
      udp.receive();
    private function RecvUdpDataHandler(obj:DatagramSocketDataEvent):void
      var str:String = obj.srcAddress;
      var srcport:int = obj.srcPort;
    ]]></mx:Script>
    <mx:Button x="206" y="134" label="Send" click="OnSend()"/>
    </mx:WindowedApplication>
    Thanks

    You can call Apple and appeal their decision if you wish to (or go back to the store and ask for a supervisor or manager to assess your device - basically dispute the genius claim and ask to have it bumped up the chain of command).  Ultimately though they are the ones who decide if your damage is a warranty-related defect or something caused by accidenatal damage or abuse.  If they say you are not eligible for a warranty repair, then you pay the fee for an out of warranty repair.

  • Datagram socket

    Can I have a datagram socket server receive messages from a stream socket client. Thanks,

    No, and you are in the wrong forum. Moving this to the Networking forum.

  • Datagram Sockets

    Hi Folks. I am curently devising an presence service andinstant messaging system on UNIX. The problem is I am looking to open a datagram socket connection with a client on another computer on port 1115. Hhow am I able to send them a message without them having to run any program on their system. How can I just send the message to them, like a proper instant messaging system.
    PS How do i get them to listen on port 1115, without them having to do anything. How can I open a server connection on port 1115 for them
    Any help is appreciated
    Ewan

    When you "proper instant messaging system" I assume you mean something like talk or ytalk rather than ICQ or YahooIM. The former have daemons that run listening for messages which are started by the system.
    the user (or administrator) of the machine is going to have to explicitly open a socket to listen for connections on the port, by running a program or by having a daemon start at boot.

  • Datagram Socket Problem !!!!!!!!!!!!!!!

    Hi to All ,
    I am facing problem regarding the Datagram Socket Programming .
    I wana to make a java program that is using the datagram socket. I wana to retrive the IP Address of all the machines that are connected in a local network by using the datagram Socket !!!!!!!!!!!!!!
    As i am new in java Socket Programming , Can any body help me How am i sends a Broadcast Packet to all the machines that are connected in a local network , so that i retrieve the IP Address of all the machines that are presented in a local network
    Please give the Solution

    You can't use any Java to find all the machines on your network (whatever that means). You will need to shell out and parse the output from the shell.
    If you want to simply use datagram sockets to send UDP broadcasts, the Javadoc covers it in some detail.
    However, UDP is called a "send and pray" protocol - you send the message and pray that the client receives it. Also, there is no acknowledgement from the client when the message is received. So, in a nutshell, you cannot use multicasts to find clients.
    You need to use some other protocols in the TCP/IP stack for finding machines on the network - and Java does not have any pre-built support for these.

  • Can u tell how to send the pictures using datagrams sockets in java

    hi to all, i am making chat application , i am datagrams socket(packets) for sending and receiving messages . datagrams only send and receive messages in bytes . can u tell me how to send the picture to other person using datagrams.
    Thankyou.

    look her
    http://forum.java.sun.com/thread.jsp?forum=31&thread=330989&tstart=0&trange=15
    and look up Serialisation

  • Help: Send and Receive through Datagram Socket

    I am trying to create a client/server using Datagram Socket (UDP) as communication. I have a Recive and a Send class that implements runnable and are responsible for receiving and sending of message. I have two other classes Server and Client that are utilizing these. Now i can get the receive and send to work fine, but i am having trouble retrieving the message from the receive thread that i created in each of server/client. I've tried inserting a method so the server/client can call on to get the message (Receive.Get_Message()) but unfortunately this isn't working as i wanted. Since my server and clients are not implemented as runnables, i can only issue the command in some serialize fashion. What i really want to do is that whenever the message is receive by the Receive thread, it will immediately be send back to server/client and display right then, independent of what i was doing. (i have a command interface for S/C so it just sits there to wait for command, now what i would like is to have the S/C display the message it gets immediately after it gets it even when it's waiting for user input. since my program is waiting for a command, i really could not use the method describe above to achieve this) Could anyone help me with this?
    Thanks!
    Hung-Hsun Su

    u cant use the observer pattern. or at least i can't figure out how to implement it with sockets.
    you should use threading.
    public void run()
      while(true)
         //keep reading from socket
         InStream output = socket.getInputStream();
         InputStreamReader ir = new InputStreamReader(output)
         BufferedReader reader = new BufferedReader(ir);
         String s = null;
         while(s == null)
           s = reader.readLine();
         //then do whatever you want to the received string "s"
    }

  • Sending a File Using DataGram Sockets

    I writting one java program that can be used to transfer a file from one computer to another computer.
    I wrote using Sockets.
    But i want to do that using DatagramSockets. Can we send a file using DataGramSockets?
    Please reply soon.

    You can use DataGram but it is harder.
    One issue is you need to retransmit missing packets. This means you need to keep track of which packets have been sent and be able to send missing ones again.
    If Socket work for you why do you want to use DataGrams

  • How to run a datagram socket client and server program

    hi,
    I am new to socket programming. I am following the tutorial of sun for socket programming...The link is
    http://java.sun.com/docs/books/tutorial/networking/datagrams/clientServer.html
    I have understood the concept, but the problem is i cannot run the program. I am using netbeans and i have created a package and stored the files QuoteServer,QuoteServerThread, QuoteClient in this package. How can i make the server program run first and then client program in netbeans
    kindly help me
    Thankyou

    I think you are trying to run both server and client
    on one machine!!!
    It is impossible, your server is blocking the port to
    send packets, so you must run client on another
    computer!!!It's not impossible to run a client and server on the same machine just for testing or as a demo. Just have the server listen on one port and the client use a different port.
    No need to use 2 seperate computers. I've done it one computer before without a problem.
    Nick

  • Datagram Sockets possible without locally available IP addresses?

    Hi everybody,
    before starting to dig into socket programming for the next few months, I'd like to get some facts clear that don't clarify to me by consuming the developer handbooks.
    I would like to send datagram packets out on all interfaces without bound sockets, i.e. I want to start something similar to a DHCP broadcast. Is this possible with Java? AFAIK always sockets are required , even for datagram communication.
    Thank you

    Hi! Thanks for you replies.
    I'm trying to create some kind of alternative host configuration protocol with a reference implementation. Since the server software will run on Java for various purposes, it would be fine if also the client software could be implemented in Java. Therefore, I'd need the possibility to send out datagrams on unconfigured network interfaces.
    As far as I have understood the DatagramSocketAPI, there's always the need to have a local socket available (IP address + port number) to actually send data - is that true?
    Thank you!

  • Acquiring local address for datagram socket created by DatagramChannel.open

    I've found that when I open an anonymous DatagramChannel (i.e. unbound, unconnected), the socket that it creates has no local address info I.e. no local port. Hopefully the example below will explain the problem...
    import java.nio.channels.DatagramChannel;
    import java.io.IOException;
    import java.net.DatagramSocket;
    import java.net.DatagramPacket;
    import java.net.InetAddress;
    public class QuickTest {
        public static void main( String[] args )    {
            try {
                DatagramChannel dc = DatagramChannel.open();
                DatagramSocket ds = dc.socket();
                byte[] ba = new byte[]{0,1,2,3};
                DatagramPacket dp = new DatagramPacket(ba,4,InetAddress.getLocalHost(),8000);
                ds.send(dp);
                System.out.println( "DatagramSocket from DatagramChannel");
                System.out.println();
                System.out.println( "          getInetAddress(): " + ds.getInetAddress());
                System.out.println( "         getLocalAddress(): " + ds.getLocalAddress ());
                System.out.println( "            getLocalPort(): " + ds.getLocalPort());
                System.out.println( "   getLocalSocketAddress(): " + ds.getLocalSocketAddress());
                System.out.println( "                 getPort(): " + ds.getPort());
                System.out.println( "  getRemoteSocketAddress(): " + ds.getRemoteSocketAddress());
                ds = new DatagramSocket();
                System.out.println();
                System.out.println();
                System.out.println();
                System.out.println( "DatagramSocket from new DatagramSocket()");
                System.out.println();
                System.out.println( "          getInetAddress(): " + ds.getInetAddress());
                System.out.println( "         getLocalAddress(): " + ds.getLocalAddress ());
                System.out.println( "            getLocalPort(): " + ds.getLocalPort());
                System.out.println( "   getLocalSocketAddress(): "    + ds.getLocalSocketAddress());
                System.out.println( "                 getPort(): " + ds.getPort());
                System.out.println( "  getRemoteSocketAddress(): " + ds.getRemoteSocketAddress());
            } catch (IOException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }Running this program yields the following information....
    DatagramSocket from DatagramChannel
    getInetAddress(): null
    getLocalAddress(): 0.0.0.0/0.0.0.0
    getLocalPort(): 0
    getLocalSocketAddress(): 0.0.0.0/0.0.0.0:0
    getPort(): -1
    getRemoteSocketAddress(): null
    DatagramSocket from new DatagramSocket()
    getInetAddress(): null
    getLocalAddress(): 0.0.0.0/0.0.0.0
    getLocalPort(): 1194
    getLocalSocketAddress(): 0.0.0.0/0.0.0.0:1194
    getPort(): -1
    getRemoteSocketAddress(): null
    I understand that the sockets address will be included in any packets sent, but why can I determine the port for one and not the other? I would like to continue using an anonymous channel, but I also would like to have the port for use in my test harness and for logging info...
    Any info and possible work around for this behavior would be much appreciated.
    tx in advance.

    This looks like a bug in the socket returned by DatagramSocketChannel and you should report it.
    In the meantime you could either just use DatagramSocket, or if you must have NIO you could try binding this socket to null or new InetSocketAddress(null,0) and see whether getLocalPort() now returns the right data.

  • Urgent helep: socket write error

              Hi All,
              My application is continuously writing the following error message to the domain
              log of WLS eventhough app is running ok
              javax.servlet.ServletException: Connection aborted by peer: socket write error
                   <<no stack trace available>>
              My major concern is that,it will fill up the heap soon.
              Did anybody run into similar issue?
              Thanks in advance.
              RC
              

    Please do not cross-port.
              RC wrote:
              > Hi All,
              > My application is continuously writing the following error message to the domain
              > log of WLS eventhough app is running ok
              >
              > javax.servlet.ServletException: Connection aborted by peer: socket write error
              > <<no stack trace available>>
              >
              > My major concern is that,it will fill up the heap soon.
              > Did anybody run into similar issue?
              > Thanks in advance.
              >
              > RC
              Rajesh Mirchandani
              Developer Relations Engineer
              BEA Support
              

  • Urgent --- Persistent socket connection?

    Hi, I have a question about the persistency of a Java Socket connection. Is it a valid idea to keep a java socket open for a long time? If so, what special care do I need to take?
    My Java TCP/IP client runs as a NT service. It keeps getting input messages every few seconds, then send it thru a socket connection to a TCP/IP server. In order to avoid the overhead of opening and closing the socket every time the client gets a message to send, I want to keep the socket connection open and reuse it.
    I was able to send hundreds of messages thru this way, then after a while, for no apparent reason,
    the socket stops working, I typically get an exception like this:
    java.net.SocketException: Connection Shutdown: JVM_recv in socket input stream read
    at java.net.SocketInputStream.socketRead(Native Method)
    at java.net.SocketInputStream.read (SocketInputStream.java:90)
    at java.net.SocketInputStream.read (SocketInputStream.java:71)
    at java.io.InputStreamReader.fill (InputStreamReader.java:163)
    at java.io.InputStreamReader.read (InputStreamReader.java:239)
    at java.io.BufferedReader.fill (BufferedReader.java:137)
    at java.io.BufferedReader.readLine (BufferedReader.java, Compiled Code)
    at java.io.BufferedReader.readLine (BufferedReader.java:329)
    My programs runs on NT4.0, single-threaded. Any input would be greatly appreciated.

    Is it a valid idea to keep a java socket open for a long time? If so, what
    special care do I need to take?Depends.
    First why keep it open? Your messages only arrive every couple of seconds, does opening/closing the connection take longer than that?
    If you must then the complication you must deal with is that your code must deal with re-establishing the connection when it does fail. Opening/closing it every time avoids that issue. The connection will fail, because computers fail, networks fail and people make mistakes. Which doesn't mean that you shouldn't but merely that you should consider the implications of why you need to keep it open.

Maybe you are looking for

  • Recording audio from a published file?

    Hi, I am using Captivate 4 with Windows XP. I am creating a soft skill learning project and what I would like to do is when the users are going through the training, I would like the published Captivate file to capture audio from the user via a micro

  • WRT600N WRT310N PPTP will not work in some cases

    Hello All, This is more of a warning than a request for help. If you are using the WRT600N or the WRT310N and you need to use PPTP VPN connections, these are not the routers for you! The PPTP support only work with MS PPTP Servers, it does not work w

  • Blocking User to change the "Configure Columns"

    Hi, I have a folder which is "Files" views Is there any to block User to change "Configure Columns" in folder option? Thanks

  • Lost between revel and photoshop 9

    Since my photos were transferred to revel I have to pay every month and my photos are not automatically transferred.  They keep saying transferr pending and when I try to log in it says photoshop not available, error 400.

  • I need to know my restrictions password

    I Need help knowing my restrictions password how do I get to know my password again?