I want to download a file using socket programming (and
not httprequest) but the DNS keeps giving me errors "IP
is ok, but the attached data is not available"
I am doing like this and the address is ok. does any one
know what is wrong here?
IPHostEntry lipa =
Dns.Resolve("19 2.168.0.2/image.jpg");
IPEndPoint lep = new
IPEndPoint(lipa .AddressList[0], 80);
Socket s = new Socket
(lep.Address.Ad dressFamily,
SocketType.Stre am,
ProtocolType.Tc p);
try
{
s.Connect(lep);
}
catch (Exception e)
{
Console.WriteLi ne
("Exception Thrown: " + e.ToString());
}
/*
byte[] msg =
Encoding.ASCII. GetBytes("This is a test");
// Blocks until send
returns.
int i = s.Send(msg, 0,
msg.Length, SocketFlags.Non e);
*/
// Blocks until read
returns.
byte[] bytes = new byte
[1024];
byte[] inBuf = new byte
[HttpBuffer];
s.Receive(inBuf , 0,
s.Available, SocketFlags.Non e);
//Displays to the screen.
//Console.WriteLi ne
(Encoding.ASCII .GetString(byte s));
s.Shutdown
(SocketShutdown .Both);
s.Close();
not httprequest) but the DNS keeps giving me errors "IP
is ok, but the attached data is not available"
I am doing like this and the address is ok. does any one
know what is wrong here?
IPHostEntry lipa =
Dns.Resolve("19 2.168.0.2/image.jpg");
IPEndPoint lep = new
IPEndPoint(lipa .AddressList[0], 80);
Socket s = new Socket
(lep.Address.Ad dressFamily,
SocketType.Stre am,
ProtocolType.Tc p);
try
{
s.Connect(lep);
}
catch (Exception e)
{
Console.WriteLi ne
("Exception Thrown: " + e.ToString());
}
/*
byte[] msg =
Encoding.ASCII. GetBytes("This is a test");
// Blocks until send
returns.
int i = s.Send(msg, 0,
msg.Length, SocketFlags.Non e);
*/
// Blocks until read
returns.
byte[] bytes = new byte
[1024];
byte[] inBuf = new byte
[HttpBuffer];
s.Receive(inBuf , 0,
s.Available, SocketFlags.Non e);
//Displays to the screen.
//Console.WriteLi ne
(Encoding.ASCII .GetString(byte s));
s.Shutdown
(SocketShutdown .Both);
s.Close();
Comment