Subversion Repositories Projects

Rev

Blame | Last modification | View Log | RSS feed

package dongfang.mkt.comm.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

import dongfang.mkt.comm.MKConnection;

public class MKTCPConnection implements MKConnection {
        private InputStream inputStream;
        private OutputStream outputStream;

        @Override
        public void init(String id) throws IOException {
                //URL url = new URL(id);
                Socket socket = new Socket("localhost", Integer.parseInt(id));
                inputStream = socket.getInputStream();
                outputStream = socket.getOutputStream();
        }

        @Override
        public InputStream getInputStream() throws IOException {
                return inputStream;
        }

        @Override
        public OutputStream getOutputStream() throws IOException {
                return outputStream;
        }
}