SHARE
TWEET
Untitled
a guest
Feb 2nd, 2012
59
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package edu.wpi.first.wpilibj.templates;
- import java.io.DataInputStream;
- import java.io.IOException;
- import javax.microedition.io.Connector;
- import javax.microedition.io.ServerSocketConnection;
- import javax.microedition.io.SocketConnection;
- /**
- *
- * @author Matt
- */
- public class Socket extends Thread {
- private ServerSocketConnection socket;
- private SocketConnection you;
- DataInputStream is;
- int datain = 0;
- public void run() {
- try {
- socket = (ServerSocketConnection) Connector.open("socket://:1234");
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- try {
- SocketConnection you = (SocketConnection)
- socket.acceptAndOpen();
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- try {
- is = you.openDataInputStream();
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- while(true) {
- try {
- datain = is.readInt();
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
- }
- }
RAW Paste Data
