Java network access specified exits iptable of Contents
- 1. Socket
- 2. Apache HttpClient
1Socket
You can specify the local IP that is used in the socket constructor, such as:
Socket socket = new Socket ("127.0.0.1", 12345, Inetaddress.getbyaddress (new byte[] { new Integer). Bytevalue (), C4/>new Integer (211). Bytevalue (), New Integer (. Bytevalue (), new Integer (2). Bytevalue (), }), 1234);
2Apache HttpClient
It can be set by HttpClient, as follows:
byte b[] = new Byte[4];b[0] = new Integer (Ten). Bytevalue (); b[1] = new Integer (211). Bytevalue (); b[2] = new integer. Bytev Alue (); b[3] = new Integer (2). Bytevalue (); Closeablehttpresponse response = null; Closeablehttpclient httpclient = Httpclients.createdefault (); HttpGet httpget = new HttpGet ("Http://localhost:8080/TestServlet"); Httpget.setconfig (Requestconfig.custom () . Setlocaladdress (inetaddress.getbyaddress (b)) . Build ());
Author:galaxy
created:2016-08-31 Wed 17:11
Emacs 24.5.6 (ORG mode 8.2.10)
Validate
Java Network access specified egress IP