Thursday, 7 June 2012

How to send HTTP request from specific IP?

How to send HTTP request from specific IP?
Hi,
I have small computer lab with the proper IP address, in this network I want to send HTTP request from any specific IP address but I want to specify my request from specific ip not from default one. I use much software but I am not able to get solution for my problem, for that I ask you please, give me some proper solution for that.
Reply With Quote
#2
Old 28-01-2010
Techguru01's Avatar
Techguru01 Techguru01 is offline
Member

Join Date: Oct 2005
Posts: 2,116
Re: How to send HTTP request from specific IP?
I make this project in my college project, in this project I use following code to send HTTP request from specific IP. I think this code will help you to solve your problem.

Quote:
public class clspeci
{
public static void main ( String args [] )
{

String argu = args [1];

try {
ADRES adres = new ADRES(argu);
HttpADRESConnection conn = (HttpADRESConnection) adres.openConnection();
InputStream arguuestStream = conn.getInputStream();
BufferedOutputStream test = new BufferedOutputStream(new FileOutputStream("your web address"), 4 * 1024);
byte b = 0;
while ((b = (byte) arguuestStream.read()) != -1) {
test.write(b);
}
test.flush();
} catch (Exception ex) {
ex.printStackTrace(System.err);
}


}
__________________
I'm the Proud Owner of the most dangerous weapon
known to man kind: Human Brain
Reply With Quote
#3
Old 28-01-2010
Techno01's Avatar
Techno01 Techno01 is offline
Member

Join Date: Apr 2008
Posts: 2,268
Re: How to send HTTP request from specific IP?
I give you ASP code for solving your problem this code take short time to compile and using this code your program give better response. In this code you have to design front end and use following in your asp file.

Quote:
xmlRequest = "" &_
"" &_
"" &_
""&AuthToken&"" &_
"
" &_
""&eBayItemID&" " &_
"
"
Reply With Quote
#4
Old 28-01-2010
Jackson2's Avatar
Jackson2 Jackson2 is offline
Member

Join Date: Apr 2008
Posts: 2,265
Re: How to send HTTP request from specific IP?
I give you better solution for that because I also face this same problem in my network some one send packets using my ip address then I find out how they do like this, for that they use following java script.

Quote:
String req = "your web address";
try {
ADRES adres = new ADRES(req);
HttpADRESConnection conn = (HttpADRESConnection) adres.openConnection();
InputStream requestStream = conn.getInputStream();
BufferedOutputStream test = new BufferedOutputStream(new FileOutputStream("url"), 4 * 1024);
byte b = 0;
while ((b = (byte) requestStream.read()) != -1) {
test.write(b);
}
test.flush();
} catch (Exception ex) {
ex.printStackTrace(System.err);
}
Reply With Quote
#5
Old 28-01-2010
johnson22's Avatar
johnson22 johnson22 is offline
Member

Join Date: May 2008
Posts: 2,111
Re: How to send HTTP request from specific IP?
Use following steps for sending HTTP request from specific IP adders
First, define an object to send. For that we write this code

Quote:
public class Message implements Serializable
{
private int senradres;
private String msge;

public Message(int id, String text) {
senradres = id;
msge = text;
}
public String getText() {
return msge;
}
}
In this step we wrap the socket's streams in object streams, and after that send the message across the socket
Quote:
Message txtmsg = new Message("45564", "Hi");
Socket socket = new Socket(host, port);
ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
out.writeObject(txtmsg);
but in this code the message can be retrieved and used by other IP and then returned object:
Quote:
ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
Message messageObject = (Message) in.readObject();
String msge = messageObject.getText();
Reply With Quote

No comments:

Post a Comment