Examples of DatagramSocket


Examples of java.net.DatagramSocket

 
  public void testTestSocket(){
    try {
     
         // get a datagram socket
       DatagramSocket socket = new DatagramSocket();

           // send request
       byte[] buf = new byte[256];
       InetAddress address = InetAddress.getByName("192.168.0.41");
       DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 4445);
      
       socket.setSoTimeout(1000);
      
       socket.send(packet);

           // get response
       packet = new DatagramPacket(buf, buf.length);
       socket.receive(packet);

       // display response
       String received = new String(packet.getData(), 0, packet.getLength());
       System.out.println("Date of the Moment: " + received);

       socket.close();
      
    } catch (Exception err) {
      log.error("[TestSocket] ",err);
    }
   
View Full Code Here

Examples of java.net.DatagramSocket

  @Override
  public void startup() {
    try {
      dgram = new DatagramPacket(discoveryPacket, discoveryPacket.length, manager.networkMulticastAddress,
          manager.networkMulticastPort);
      socket = new DatagramSocket();
    } catch (Exception e) {
      OLogManager.instance().error(this, "Can't startup distributed server discovery signaler", e);
    }
    super.startup();
  }
View Full Code Here

Examples of java.net.DatagramSocket

    assertEquals("com.bea.sipservlet.tck.apps.spectestapp.uas", message.getHeader("application-name"));
  }

  private void send(String message) throws Exception
  {
    DatagramSocket ds = new DatagramSocket();
   
    byte[] b = message.getBytes("UTF-8");
    DatagramPacket packet = new DatagramPacket(b, 0, b.length, InetAddress.getLocalHost(), 5040);
 
    ds.send(packet);
  }
View Full Code Here

Examples of java.net.DatagramSocket

  }
 
  protected DatagramSocket newDatagramSocket() throws IOException
  {
    if (getHost() == null)
      _datagramSocket = new DatagramSocket(getPort());
    else
      _datagramSocket = new DatagramSocket(getPort(), InetAddress.getByName(getHost()));

    return _datagramSocket;
  }
View Full Code Here

Examples of java.net.DatagramSocket

    server.start();
    byte[] b = __msg.getBytes();
    DatagramPacket packet = new DatagramPacket(b, b.length);
    packet.setAddress(InetAddress.getLocalHost());
    packet.setPort(5060);
    DatagramSocket socket = new DatagramSocket();
    socket.send(packet);
  }
View Full Code Here

Examples of java.net.DatagramSocket

    }

    public void init() throws Exception
    {
        String fileName = getFileName("hello", _audioPayloadType);
        DatagramSocket datagramSocket = new DatagramSocket();
        UdpEndPoint udpEndPoint = new UdpEndPoint(datagramSocket);
        _player = new Player(fileName, _host, _destPort, _audioPayloadType,
                udpEndPoint);
        _dtmfHandler = new DtmfHandler(_dtmfPayloadType, udpEndPoint);
        _player.init();
        _dtmfHandler.init();
        _dtmfHandlerThread = new Thread(_dtmfHandler);
        _player.addEventListener(this);
        _dtmfHandler.addDtmfListener(this);
        _filenames = Collections.synchronizedList(new ArrayList<String>());
        _localPort = datagramSocket.getLocalPort();
        _timer = new Timer();
        _playingMutex = new Object();
        synchronized (_playingMutex)
        {
            _playing = false;
View Full Code Here

Examples of java.net.DatagramSocket

    return new Connection(host, port);
  }
 
  public DatagramSocket newDatagramSocket() throws SocketException
  {
    return new DatagramSocket(getPort(), getHostAddr());
  }
View Full Code Here

Examples of java.net.DatagramSocket

  }
 
  protected DatagramSocket newDatagramSocket() throws IOException
  {
    if (getHost() == null)
      _datagramSocket = new DatagramSocket(getPort());
    else
      _datagramSocket = new DatagramSocket(getPort(), InetAddress.getByName(getHost()));

    return _datagramSocket;
  }
View Full Code Here

Examples of java.net.DatagramSocket

    private static void startUdpDdaemon(final JMeterEngine engine) {
        int port = JMeterUtils.getPropDefault("jmeterengine.nongui.port", UDP_PORT_DEFAULT); // $NON-NLS-1$
        int maxPort = JMeterUtils.getPropDefault("jmeterengine.nongui.maxport", 4455); // $NON-NLS-1$
        if (port > 1000){
            final DatagramSocket socket = getSocket(port, maxPort);
            if (socket != null) {
                Thread waiter = new Thread("UDP Listener"){
                    @Override
                    public void run() {
                        waitForSignals(engine, socket);
View Full Code Here

Examples of java.net.DatagramSocket

            socket.close();
        }
    }

    private static DatagramSocket getSocket(int udpPort, int udpPortMax) {
        DatagramSocket socket = null;
        int i = udpPort;
        while (i<= udpPortMax) {
            try {
                socket = new DatagramSocket(i);
                break;
            } catch (SocketException e) {
                i++;
            }           
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.