Article View: chile.comp.programacion
Article #192Problema con Socket y Unix
From: Pintamono
Date: Thu, 20 Aug 2009 14:58
Date: Thu, 20 Aug 2009 14:58
45 lines
2429 bytes
2429 bytes
Que tal,
Tengo un problema, he tenido que realizar una conexion via socket (mi
primera vez) a un servidor Unix al cual le envio un mensaje pero al
momento de esperar respuesta se queda esperando y finalmente cierra la
conexion por "timedout", segun la persona encargada del servidor Unix el
servicio envia respuesta pero al parecer mi cliente no es capaz de
interpretarla o algo asi...
mi codigo seria asi: (codigo en c#)
IPAddress ipAddress = Dns.GetHostEntry(Server).AddressList[0];
IPEndPoint remoteEP = new IPEndPoint(ipAddress, Port);
Socket client = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
try
{
client.ReceiveTimeout = 8000;
client.Connect(remoteEP);
byte[] msg = Encoding.ASCII.GetBytes(psMensaje);
int bytesSent = client.Send(msg);
int bytesRec = client.Receive(bytes); ***
psMensaje = Encoding.ASCII.GetString(bytes, 0, bytesRec);
client.Shutdown(SocketShutdown.Both);
client.Close();
return psMensaje;
}
catch ...
*** En esta linea se queda por 8 segundos, que es lo que le tengo
definido, y luego se cae. Si quito "client.ReceiveTimeout" se queda
esperando eternamente...
Mi duda, hay que hacer algo especial para conectarse via socket con
unix? tengo algo mal en mi codigo (extraido de MSDN)?
Muchisimas gracias.
Otra duda, el otro dia alguien me comento que las conexiones por socket
eran "antiguas", si ya no se usa socket �que se usa?. Gracias
Saludos!
Technical Details
Message-ID:
<h6jbbp$f8o$1@tucows.gtdinternet.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!news-xfer.nntp.sonic.net!news.kjsl.com!news.nivel5.cl!news.gtdinternet.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: e499fe1f24,4c61272918c3354f,start X-Google-Attributes: gide499fe1f24,public,usenet X-Google-NewGroupId: yes X-Google-Language: SPANISH,ASCII Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!news-xfer.nntp.sonic.net!news.kjsl.com!news.nivel5.cl!news.gtdinternet.com!not-for-mail From: Pintamono <Pintamono@NoMandeWeas.kk> Newsgroups: chile.comp.programacion Subject: Problema con Socket y Unix Date: Thu, 20 Aug 2009 10:58:08 -0400 Organization: Gtd Internet S.A. Lines: 45 Message-ID: <h6jbbp$f8o$1@tucows.gtdinternet.com> NNTP-Posting-Host: 201.238.215.146 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: tucows.gtdinternet.com 1250767033 15640 201.238.215.146 (20 Aug 2009 11:17:13 GMT) X-Complaints-To: usenet@gtdinternet.com NNTP-Posting-Date: Thu, 20 Aug 2009 11:17:13 +0000 (UTC) User-Agent: Thunderbird 2.0.0.22 (Windows/20090605)