H
Henrik
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("192.168.0.2/image.jpg");
IPEndPoint lep = new
IPEndPoint(lipa.AddressList[0], 80);
Socket s = new Socket
(lep.Address.AddressFamily,
SocketType.Stream,
ProtocolType.Tcp);
try
{
s.Connect(lep);
}
catch (Exception e)
{
Console.WriteLine
("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.None);
*/
// Blocks until read
returns.
byte[] bytes = new byte
[1024];
byte[] inBuf = new byte
[HttpBuffer];
s.Receive(inBuf, 0,
s.Available, SocketFlags.None);
//Displays to the screen.
//Console.WriteLine
(Encoding.ASCII.GetString(bytes));
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("192.168.0.2/image.jpg");
IPEndPoint lep = new
IPEndPoint(lipa.AddressList[0], 80);
Socket s = new Socket
(lep.Address.AddressFamily,
SocketType.Stream,
ProtocolType.Tcp);
try
{
s.Connect(lep);
}
catch (Exception e)
{
Console.WriteLine
("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.None);
*/
// Blocks until read
returns.
byte[] bytes = new byte
[1024];
byte[] inBuf = new byte
[HttpBuffer];
s.Receive(inBuf, 0,
s.Available, SocketFlags.None);
//Displays to the screen.
//Console.WriteLine
(Encoding.ASCII.GetString(bytes));
s.Shutdown
(SocketShutdown.Both);
s.Close();