Results 1 to 2 of 2
  1. #1
    newbie14 is offline Member
    Join Date
    Feb 2010
    Posts
    63
    Rep Power
    0

    Default Socket conversion tcp to udp

    Currently I have socket of the tcp version.

    Java Code:
    final ServerSocket serverSocketConn = new ServerSocket(9000);				
    			   while (true) 
    					{
    						try 
    						{
    					            Socket socketConn1 = serverSocketConn.accept();
                                    new Thread(new ConnectionHandler(socketConn1)).start();			            
    						}
    						catch(Exception e)
    						{
    							System.out.println("MyError:Socket Accepting has been caught in main loop."+e.toString());
    						    e.printStackTrace(System.out);
    						}
    					}
    class ConnectionHandler implements Runnable {
    
        private Socket receivedSocketConn1;
        ConnectionHandler(Socket receivedSocketConn1) {
          this.receivedSocketConn1=receivedSocketConn1;
        }
    
         try{
              BufferedWriter bWriter =  new BufferedWriter(new OutputStreamWriter(receivedSocketConn1.getOutputStream()));
             BufferedReader bReader = new BufferedReader(new InputStreamReader(receivedSocketConn1.getInputStream()));
         
         }
    
    }
    I managed to convert this final DatagramSocket serverSocketConn = new DatagramSocket (9000); now I am stuck here Socket socketConn1 = serverSocketConn.accept();
    new Thread(new ConnectionHandler(socketConn1)).start(); can I use this or I need to create a manual thread pooling for UDP ?

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Socket conversion tcp to udp

    Is this what you're looking for? DatagramSocket (Java Platform SE 6)

    The API docs are a great resource. You should browse them to become familiar with that's in there, and refer to them any time you wonder how something works.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Java Socket Exception Socket Closed
    By premkumar.rj in forum New To Java
    Replies: 0
    Last Post: 02-07-2014, 06:07 AM
  2. Replies: 16
    Last Post: 08-08-2013, 05:34 PM
  3. Socket Programming ERROR : Socket not connected
    By vishrut_n_shah in forum Networking
    Replies: 0
    Last Post: 11-04-2011, 10:32 AM
  4. Replies: 1
    Last Post: 07-02-2010, 02:18 PM
  5. append response to the request from Socket and write to another socket
    By vaibhav_singh_vs@yahoo.co in forum Networking
    Replies: 3
    Last Post: 04-17-2009, 08:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •