當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalSocketAddress類代碼示例

本文整理匯總了Java中android.net.LocalSocketAddress的典型用法代碼示例。如果您正苦於以下問題:Java LocalSocketAddress類的具體用法?Java LocalSocketAddress怎麽用?Java LocalSocketAddress使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LocalSocketAddress類屬於android.net包,在下文中一共展示了LocalSocketAddress類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createSockets

import android.net.LocalSocketAddress; //導入依賴的package包/類
protected void createSockets() throws IOException {

		final String LOCAL_ADDR = "net.majorkernelpanic.streaming-";

		for (int i=0;i<10;i++) {
			try {
				mSocketId = new Random().nextInt();
				mLss = new LocalServerSocket(LOCAL_ADDR+mSocketId);
				break;
			} catch (IOException e1) {}
		}

		mReceiver = new LocalSocket();
		mReceiver.connect( new LocalSocketAddress(LOCAL_ADDR+mSocketId));
		mReceiver.setReceiveBufferSize(500000);
		mReceiver.setSoTimeout(3000);
		mSender = mLss.accept();
		mSender.setSendBufferSize(500000);
	}
 
開發者ID:ghazi94,項目名稱:Android_CCTV,代碼行數:20,代碼來源:MediaStream.java

示例2: DaemonMonitorImpl

import android.net.LocalSocketAddress; //導入依賴的package包/類
DaemonMonitorImpl(Context context, File configFile, Notification notification2, Preferences2 preferences2, CmdLineBuilder cmdLineBuilder, IfConfigFactory ifConfigFactory)
{
	mContext = context;
	mConfigFile = configFile;
       mNotification2 = notification2;
       mPreferences2 = preferences2;
       mCmdLineBuilder = cmdLineBuilder;
       mIfConfigFactory = ifConfigFactory;

       mLog = new LogFile( mPreferences2.logFileFor() );
	mTagDaemonMonitor = String.format("OpenVPN-DaemonMonitor[%s]", mConfigFile);

       mgmtSocket = new LocalSocketAddress(
               new File( mContext.getDir( "mgmt", Context.MODE_PRIVATE ), "mgmt.socket" ).getAbsolutePath(),
               LocalSocketAddress.Namespace.FILESYSTEM
       );

       reattach();
   }
 
開發者ID:serega1983,項目名稱:android-openvpn-settings,代碼行數:20,代碼來源:DaemonMonitorImpl.java

示例3: createSockets

import android.net.LocalSocketAddress; //導入依賴的package包/類
protected void createSockets() throws IOException {

		final String LOCAL_ADDR = "net.majorkernelpanic.streaming-";

		for (int i=0;i<10;i++) {
			try {
				mSocketId = new Random().nextInt();
				mLss = new LocalServerSocket(LOCAL_ADDR+mSocketId);
				break;
			} catch (IOException e1) {}
		}

		mReceiver = new LocalSocket();
		mReceiver.connect( new LocalSocketAddress(LOCAL_ADDR+mSocketId));
		mReceiver.setReceiveBufferSize(1000000);
		mReceiver.setSoTimeout(3000);
		mSender = mLss.accept();
		mSender.setSendBufferSize(1000000);
	}
 
開發者ID:Oo-Dev,項目名稱:OoDroid2,代碼行數:20,代碼來源:MediaStream.java

示例4: createSockets

import android.net.LocalSocketAddress; //導入依賴的package包/類
protected void createSockets() throws IOException {

		final String LOCAL_ADDR = "edu.ucsb.cs.capstone.letmypeoplecode.smartrover.streaming-";

		for (int i=0;i<10;i++) {
			try {
				mSocketId = new Random().nextInt();
				mLss = new LocalServerSocket(LOCAL_ADDR+mSocketId);
				break;
			} catch (IOException e1) {}
		}

		mReceiver = new LocalSocket();
		mReceiver.connect( new LocalSocketAddress(LOCAL_ADDR+mSocketId));
		mReceiver.setReceiveBufferSize(500000);
		mReceiver.setSoTimeout(3000);
		mSender = mLss.accept();
		mSender.setSendBufferSize(500000);
	}
 
開發者ID:sciencectn,項目名稱:SmartRover,代碼行數:20,代碼來源:MediaStream.java

示例5: simplestGet

import android.net.LocalSocketAddress; //導入依賴的package包/類
@Test(timeout = 1000)
public void simplestGet() throws IOException, InterruptedException {
	// given
	Service service = startService();

	// when
	LocalSocket clientSocket = new LocalSocket();
	clientSocket.connect(new LocalSocketAddress("doesn't matter now"));
	OutputStream os = clientSocket.getOutputStream();
	os.write(GET_1.getBytes());
	os.close();

	// then
	InputStream is = clientSocket.getInputStream();
	String response = IOUtils.toString(is);
	System.out.println("response: " + response);
	String expectedBody = new Test1().test();
	assertThat(response, containsString(expectedBody));
}
 
開發者ID:mywebio,項目名稱:mywebio-sdk,代碼行數:20,代碼來源:WowFirstWorkingTest.java

示例6: simplestPost

import android.net.LocalSocketAddress; //導入依賴的package包/類
@Test(timeout = 1000)
public void simplestPost() throws IOException, InterruptedException {
	// given
	Service service = startService();

	// when
	LocalSocket clientSocket = new LocalSocket();
	clientSocket.connect(new LocalSocketAddress("doesn't matter now"));
	OutputStream os = clientSocket.getOutputStream();
	os.write(POST_1.getBytes());
	os.close();

	// then
	InputStream is = clientSocket.getInputStream();
	String response = IOUtils.toString(is);
	System.out.println("response: " + response);
	String expectedBody = new TestPost().post(11, "somename");
	assertThat(response, containsString(expectedBody));
}
 
開發者ID:mywebio,項目名稱:mywebio-sdk,代碼行數:20,代碼來源:WowFirstWorkingTest.java

示例7: shouldParseLongGetRequests

import android.net.LocalSocketAddress; //導入依賴的package包/類
@Test(timeout = 1000)
public void shouldParseLongGetRequests() throws IOException {
	// given
	Service service = startService();

	// when
	LocalSocket clientSocket = new LocalSocket();
	clientSocket.connect(new LocalSocketAddress("doesn't matter now"));
	OutputStream os = clientSocket.getOutputStream();
	os.write(GET_LONG_1.getBytes()); // two long requests
	os.write(GET_LONG_1.getBytes());
	os.close();

	// then
	InputStream is = clientSocket.getInputStream();
	String response = IOUtils.toString(is);
	System.out.println("response: " + response);
	String expectedBody = new Test1().test();
	assertThat(response, containsString(expectedBody));
}
 
開發者ID:mywebio,項目名稱:mywebio-sdk,代碼行數:21,代碼來源:WowFirstWorkingTest.java

示例8: headersShouldBeDecoded

import android.net.LocalSocketAddress; //導入依賴的package包/類
@Test(timeout = 1000)
public void headersShouldBeDecoded() throws IOException {
	// given
	Service service = new Service();
	service.onCreate();
	service.onStartCommand(new Intent(), 0, 0);

	// when
	LocalSocket clientSocket = new LocalSocket();
	clientSocket.connect(new LocalSocketAddress("doesn't matter now"));
	OutputStream os = clientSocket.getOutputStream();
	os.write(GET_1.getBytes());
	os.close();

	// then
	InputStream is = clientSocket.getInputStream();
	String response = IOUtils.toString(is);
	System.out.println("response: " + response);
	assertThat(response, containsString("localhost"));
	assertThat(response, containsString("b=2"));
	assertThat(response, containsString("a=1"));
}
 
開發者ID:mywebio,項目名稱:mywebio-sdk,代碼行數:23,代碼來源:HeaderTest.java

示例9: cookieShouldBeReturned

import android.net.LocalSocketAddress; //導入依賴的package包/類
@Test(timeout = 1000)
public void cookieShouldBeReturned() throws IOException, InterruptedException {
	// given
	Service service = new Service();
	service.onCreate();
	service.onStartCommand(new Intent(), 0, 0);

	// when
	LocalSocket clientSocket = new LocalSocket();
	clientSocket.connect(new LocalSocketAddress("doesn't matter now"));
	OutputStream os = clientSocket.getOutputStream();
	os.write(GET_1.getBytes());
	os.close();

	// then
	InputStream is = clientSocket.getInputStream();
	String response = IOUtils.toString(is);
	System.out.println("response: " + response);
	String expectedBody = "Set-Cookie: COOKIE_NAME=cookieValuecookieValue";
	assertThat(response, containsString(expectedBody));
}
 
開發者ID:mywebio,項目名稱:mywebio-sdk,代碼行數:22,代碼來源:CookieTest.java

示例10: cookieShouldBeAccepted

import android.net.LocalSocketAddress; //導入依賴的package包/類
@Test(timeout = 1000)
public void cookieShouldBeAccepted() throws IOException, InterruptedException {
	// given
	Service service = new Service();
	service.onCreate();
	service.onStartCommand(new Intent(), 0, 0);

	// when
	LocalSocket clientSocket = new LocalSocket();
	clientSocket.connect(new LocalSocketAddress("doesn't matter now"));
	OutputStream os = clientSocket.getOutputStream();
	os.write(GET_2.getBytes());
	os.close();

	// then
	InputStream is = clientSocket.getInputStream();
	String response = IOUtils.toString(is);
	System.out.println("response: " + response);
	String expectedBody = "cookieValuecookieValue";
	assertThat(response, containsString(expectedBody));
}
 
開發者ID:mywebio,項目名稱:mywebio-sdk,代碼行數:22,代碼來源:CookieTest.java

示例11: LocalProxySocket

import android.net.LocalSocketAddress; //導入依賴的package包/類
public LocalProxySocket(Socket original) throws TorException {
    super();
    try {
        // Prepare LocalSocket which will be used to trick the SSLSocket (or any other one)
        localSocketSend = new LocalSocket();
        // Local socket name
        String socketName = "local" + UUID.randomUUID();
        localServerSocket = new LocalServerSocket(socketName);
        localSocketSend.connect(new LocalSocketAddress(socketName));
        localSocketRecv = localServerSocket.accept();
        this.originalSocket = original;
        // Create 2 Threads which are taking care of the communication between the LocalSocket and the original Socket
        LocalProxyWorker lpw1 = new LocalProxyWorker(localSocketRecv.getInputStream(), originalSocket.getOutputStream(), "to");
        LocalProxyWorker lpw2 = new LocalProxyWorker(originalSocket.getInputStream(), localSocketRecv.getOutputStream(), "from");
        Thread t1 = new Thread(lpw1);
        Thread t2 = new Thread(lpw2);
        t1.start();
        t2.start();
        // Prepare this Socket to contain the FileDescriptor of the LocalSocket
        FileDescriptor fd = localSocketSend.getFileDescriptor();
        SocketImpl socketImpl = (SocketImpl) Class.forName("java.net.PlainSocketImpl").getConstructor(FileDescriptor.class).newInstance(fd);
        Field implField = this.getClass().getSuperclass().getDeclaredField("impl");
        implField.setAccessible(true);
        implField.set(this, socketImpl);
    } catch (Exception e) {
        LOG.debug("Got Exception while trying to create LocalProxySocket", e);
        throw new TorException("could not create LocalProxySocket", e);
    }
}
 
開發者ID:B4dT0bi,項目名稱:silvertunnel-ng,代碼行數:30,代碼來源:LocalProxySocket.java

示例12: createSockets

import android.net.LocalSocketAddress; //導入依賴的package包/類
protected void createSockets() throws IOException {

		if (sPipeApi == PIPE_API_LS) {
			
			final String LOCAL_ADDR = "com.galuu.ev3videocontrol.streaming-";
	
			for (int i=0;i<10;i++) {
				try {
					mSocketId = new Random().nextInt();
					mLss = new LocalServerSocket(LOCAL_ADDR+mSocketId);
					break;
				} catch (IOException e1) {}
			}
	
			mReceiver = new LocalSocket();
			mReceiver.connect( new LocalSocketAddress(LOCAL_ADDR+mSocketId));
			mReceiver.setReceiveBufferSize(500000);
			mReceiver.setSoTimeout(3000);
			mSender = mLss.accept();
			mSender.setSendBufferSize(500000);
			
		} else {
			Log.e(TAG, "parcelFileDescriptors createPipe version = Lollipop");
			mParcelFileDescriptors = ParcelFileDescriptor.createPipe();
			mParcelRead = new ParcelFileDescriptor(mParcelFileDescriptors[0]);
			mParcelWrite = new ParcelFileDescriptor(mParcelFileDescriptors[1]);
		}
	}
 
開發者ID:galme,項目名稱:ROLF-EV3,代碼行數:29,代碼來源:MediaStream.java

示例13: LocalSocketThread

import android.net.LocalSocketAddress; //導入依賴的package包/類
@SuppressLint("UseSparseArrays")
public LocalSocketThread(String socketPath) {
    mSocketPath = new LocalSocketAddress(socketPath);
    mInputStream = null;
    mOutputStream = null;
    mMessages = new HashMap<>();
}
 
開發者ID:anticomarley,項目名稱:Android-IMSI-Catcher-Detector,代碼行數:8,代碼來源:SamsungMulticlientRilExecutor.java

示例14: createSockets

import android.net.LocalSocketAddress; //導入依賴的package包/類
protected void createSockets() throws IOException {

		if (sPipeApi == PIPE_API_LS) {
			
			final String LOCAL_ADDR = "net.majorkernelpanic.streaming-";
	
			for (int i=0;i<10;i++) {
				try {
					mSocketId = new Random().nextInt();
					mLss = new LocalServerSocket(LOCAL_ADDR+mSocketId);
					break;
				} catch (IOException e1) {}
			}
	
			mReceiver = new LocalSocket();
			mReceiver.connect( new LocalSocketAddress(LOCAL_ADDR+mSocketId));
			mReceiver.setReceiveBufferSize(500000);
			mReceiver.setSoTimeout(3000);
			mSender = mLss.accept();
			mSender.setSendBufferSize(500000);
			
		} else {
			Log.e(TAG, "parcelFileDescriptors createPipe version = Lollipop");
			mParcelFileDescriptors = ParcelFileDescriptor.createPipe();
			mParcelRead = new ParcelFileDescriptor(mParcelFileDescriptors[0]);
			mParcelWrite = new ParcelFileDescriptor(mParcelFileDescriptors[1]);
		}
	}
 
開發者ID:hypeapps,項目名稱:Endoscope,代碼行數:29,代碼來源:MediaStream.java

示例15: connectLocalServer

import android.net.LocalSocketAddress; //導入依賴的package包/類
/**
 * Creates a socket to write the AR Animation data.
 *
 * @param socketAddress LocalSocket address.
 */
private void connectLocalServer(final String socketAddress) {
    closeLocalServer();

    try {
        mLocalRenderAnimationSocket = new LocalSocket();
        mLocalRenderAnimationSocket.connect(new LocalSocketAddress(socketAddress));
    } catch (Exception e) {
        if (Dbg.DEBUG) {
            Dbg.e("Failed connecting socket for AR Animation data.");
        }
    }
}
 
開發者ID:sonyxperiadev,項目名稱:DroneControl,代碼行數:18,代碼來源:SmartEyeglassControlUtils.java


注:本文中的android.net.LocalSocketAddress類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。