🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #193

Re: Problema con Socket y Unix

#193
From: Pintamono
Date: Thu, 20 Aug 2009 18:53
50 lines
2684 bytes
Solucionado...

era Capa 8 ��

Pintamono escribi�:
> 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: <h6jp47$hk9$1@tucows.gtdinternet.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news.kjsl.com!news.nivel5.cl!news.gtdinternet.com!not-for-mail
References: <h6jbbp$f8o$1@tucows.gtdinternet.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: e499fe1f24,4c61272918c3354f
X-Google-Attributes: gide499fe1f24,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news.kjsl.com!news.nivel5.cl!news.gtdinternet.com!not-for-mail
From: Pintamono <Pintamono@NoMandeWeas.kk>
Newsgroups: chile.comp.programacion
Subject: Re: Problema con Socket y Unix
Date: Thu, 20 Aug 2009 14:53:03 -0400
Organization: Gtd Internet S.A.
Lines: 50
Message-ID: <h6jp47$hk9$1@tucows.gtdinternet.com>
References: <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 1250781127 18057 201.238.215.146 (20 Aug 2009 15:12:07 GMT)
X-Complaints-To: usenet@gtdinternet.com
NNTP-Posting-Date: Thu, 20 Aug 2009 15:12:07 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.22 (Windows/20090605)
In-Reply-To: <h6jbbp$f8o$1@tucows.gtdinternet.com>