Salve a tutti.
ho il seguente codice:
public void Trasfer(string parametro)
{
//scelgo l'host
strParametro=parametro;
IPHostEntry IPHost = Dns.Resolve("www.siti-web.com");
Console.WriteLine(IPHost.HostName);
string []aliases = IPHost.Aliases;
IPAddress[] addr = IPHost.AddressList;
Console.WriteLine(addr[0]);
EndPoint ep = new IPEndPoint(addr[0],80);
Socket sock = new Socket(AddressFamily.InterNetwork,SocketType.Strea m,ProtocolType.Tcp);
sock.Connect(ep);
if(sock.Connected)
Console.WriteLine("OK");
Encoding ASCII = Encoding.ASCII;
string Get=@"&user=gg";
string protocol="HTTP/1.0" ;
string br="\r\n" ;
string target="/pagina.php" ;
string req_body="" ;
req_body+="¶metro="+strParametro;
string headers="POST "+target+" "+protocol+br ;
headers+="Content-Type: application/x-www-form-urlencoded"+br ;
headers+="Content-Length: "+req_body.Length+br+br ;
Byte[] ByteGet = ASCII.GetBytes(headers+req_body);
Byte[] RecvBytes = new Byte[2256];
sock.Send(ByteGet, ByteGet.Length, 0);
Int32 bytes = sock.Receive(RecvBytes,0, RecvBytes.Length, 0);
string strRetPage="";
strRetPage = ASCII.GetString(RecvBytes, 0,RecvBytes.Length);
if(strRetPage.IndexOf("risultatook")>0)
mOk=true;
strRetPage = null;
strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes);
sock.Shutdown(SocketShutdown.Both);
sock.Close();
}
che dovreppe connettersi alla pagina web pagina.php e
ricevere una risposta.
il problema deve essere sul target(/pagina.php),io ci metto solo quello ma sul server il file sta nella directory httpdocs.
QUalcuno sa aiutarmi???

