{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Errorsimulator - )[email protected]@version 1.00...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/** * @(#)Errorsimulator.java * * * @author * @version 1.00 2009/8/2 */ import java.io.*; import java.net.*; import java.util.*; public class Errorsimulator implements Runnable { p DatagramPacket receivePacket,sendPacket; DatagramSocket listningSocket,sendingSocket; D String receivedOpcode ,changedOpcode; int serverPort, changedPort; int delay,clientPort; InetAddress clientAddress,serverAddress; // this array will contain the message from received packet byte request [] = new byte [512]; public void run(){ p //receives the packets try{ listningSocket = new DatagramSocket(68); }catch(SocketException e){ System.err.println(e); } try{ sendingSocket = new DatagramSocket(); }catch(SocketException e){ System.err.println(e); S } //packet created receivePacket = new DatagramPacket(request,request.length); r //receiveing socket try{ listningSocket.receive(receivePacket); }catch(IOException e){ System.out.println(e); S } //getting the address and port of the client clientAddress(receivePacket); c //extract data from packet request = receivePacket.getData(); //change bytes to string String received = new String(request); //get the first two bytes that contain opcode
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
receivedOpcode = new String(received.substring(0,2));
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern