Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 05-12-2007
wofox wofox is offline
Miembro
 
Registrado: dic 2007
Posts: 28
Poder: 0
wofox Va por buen camino
[Pedido] Tutorial sobre chat con sockets.

Hola, necesito aprender a crear un chat en sockets desde 0. Descargué algunos ya hechos pero no los entendí por lo que agradecería que alguien posteara un tutorial sobre cómo hacerlo paso a paso.
Muchas gracias, espero su colaboración.
Responder Con Cita
  #2  
Antiguo 05-12-2007
[egostar] egostar is offline
Registrado
 
Registrado: feb 2006
Posts: 6.556
Poder: 25
egostar Va camino a la fama
Cita:
Empezado por wofox Ver Mensaje
Hola, necesito aprender a crear un chat en sockets desde 0. Descargué algunos ya hechos pero no los entendí por lo que agradecería que alguien posteara un tutorial sobre cómo hacerlo paso a paso.
Muchas gracias, espero su colaboración.
Hola wofox bienvenido al club, te recomiendo que leas nuestra guia de estilo.

No nos dices que versión de delphi usas, pero hasta donde se, hay un ejemplo de chat en las versiones de delphi en la carpeta DEMOS.

No se si por ahi hay algún tutorial de eso que pides.

Salud OS
__________________
"La forma de empezar es dejar de hablar y empezar a hacerlo." - Walt Disney
Responder Con Cita
  #3  
Antiguo 05-12-2007
wofox wofox is offline
Miembro
 
Registrado: dic 2007
Posts: 28
Poder: 0
wofox Va por buen camino
Estoy usando Borland Delphi 7, muchas gracias por decirme donde está el chat lo acabo de encontrar.
Espero visitar este foro muy seguido y poco a poco ir aprendiendo.
Gracias por la ayuda pero me gustaría que alguien me explicara el codigo comentándolo, les dejo el código:
Código:
constructor TClientDataThread.Create(CreateSuspended: Boolean);
begin
  inherited Create(CreateSuspended);
  FreeOnTerminate := true;
  ListBuffer := TStringList.Create;
end;

procedure TClientDataThread.Terminate;
begin
  ListBuffer.Free;
  inherited;
end;

procedure TClientDataThread.Execute;
begin
  Synchronize(synchAddDataToControl);
end;

procedure TClientDataThread.synchAddDataToControl;
begin
 TargetList.AddStrings(ListBuffer);
end;
//------------- end TClientDataThread impl -------------------------------------


procedure TForm1.btnActivateServerClick(Sender: TObject);
begin
  TcpServer1.LocalPort := edtLocalPort.Text;
  TcpServer1.Active := True;
end;         

procedure TForm1.btnSendClick(Sender: TObject);
var
  I: Integer;
begin
  TcpClient1.RemoteHost := edtRemoteHost.Text;
  TcpClient1.RemotePort := edtRemotePort.Text;
  try
    if TcpClient1.Connect then
      for I := 0 to memSend.Lines.Count - 1 do
      TcpClient1.Sendln(memSend.Lines[i]);
  finally
    TcpClient1.Disconnect;
  end;
end;

procedure TForm1.TcpServer1Accept(sender: TObject;
  ClientSocket: TCustomIpClient);
var
  s: string;
  DataThread: TClientDataThread;
begin
  // create thread
  DataThread:= TClientDataThread.Create(true);
  // set the TagetList to the gui list that you
  // with to synch with.
  DataThread.TargetList := memRecv.lines;

  // Load the Threads ListBuffer
  DataThread.ListBuffer.Add('*** Connection Accepted ***');
  DataThread.ListBuffer.Add('Remote Host: ' + ClientSocket.LookupHostName(ClientSocket.RemoteHost) +
   ' (' + ClientSocket.RemoteHost + ')');
  DataThread.ListBuffer.Add('===== Begin message =====');
  s := ClientSocket.Receiveln;
  while s <> '' do
  begin
    DataThread.ListBuffer.Add(s);
    s := ClientSocket.Receiveln;
  end;
  DataThread.ListBuffer.Add('===== End of message =====');

  // Call Resume which will execute and synch the
  // ListBuffer with the TargetList
  DataThread.Resume;

end;

Última edición por wofox fecha: 05-12-2007 a las 19:49:40.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
referencia sobre sockets fer21unmsm Varios 2 06-05-2006 00:31:53
Tutorial sobre FastReport bustio Impresión 0 19-10-2005 16:15:10
Tutorial sobre imagenes en TTreeView bustio OOP 1 26-01-2005 05:46:09
Sobre Sockets Rabata Varios 3 06-11-2003 18:31:55
ejemplo sobre sockets taurux Varios 0 18-06-2003 18:14:52


La franja horaria es GMT +2. Ahora son las 16:19:19.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi