SHARE
TWEET

Untitled

a guest Feb 2nd, 2012 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package edu.wpi.first.wpilibj.templates;
  6.  
  7. import java.io.DataInputStream;
  8. import java.io.IOException;
  9. import javax.microedition.io.Connector;
  10. import javax.microedition.io.ServerSocketConnection;
  11. import javax.microedition.io.SocketConnection;
  12.  
  13. /**
  14.  *
  15.  * @author Matt
  16.  */
  17. public class Socket extends Thread {
  18.    
  19.     private ServerSocketConnection socket;
  20.     private SocketConnection you;
  21.     DataInputStream is;
  22.     int datain = 0;
  23.     public void run() {
  24.        
  25.         try {
  26.             socket = (ServerSocketConnection) Connector.open("socket://:1234");
  27.            
  28.         } catch (IOException ex) {
  29.             ex.printStackTrace();
  30.         }
  31.        
  32.         try {
  33.            SocketConnection you = (SocketConnection)
  34.                     socket.acceptAndOpen();
  35.         } catch (IOException ex) {
  36.             ex.printStackTrace();
  37.         }
  38.        
  39.         try {
  40.             is = you.openDataInputStream();
  41.         } catch (IOException ex) {
  42.             ex.printStackTrace();
  43.         }
  44.         while(true) {
  45.         try {
  46.              datain = is.readInt();
  47.         } catch (IOException ex) {
  48.             ex.printStackTrace();
  49.         }
  50.         }
  51.    
  52.    
  53.     }
  54.   }
RAW Paste Data
Top