c0smyn Posted November 26, 2008 Report Posted November 26, 2008 Client1. Adaugam pe form un tcpclient, 3edit , 2buttons2. La edit1 punem la text "Adresa IP" 3. La edit2 punem la text "Port"4. La edit3 la text punem "Mesaj"5. La button1, punem la caption "Conectare"6. La button2, punem la caption "Trimite"7. 2click pe button1 si punem acest codtcpclient1.remotehost := edit1.text; [color=lime]//setam adresa ip[/color]tcpclient1.remoteport := edit2.text; [color=lime]//setam portul[/color]tcpclient1.connect; [color=lime]//conectare[/color]8. 2click pe tcpclient si punem acest codshowmessage('Esti conectat pe '+tcpclient1.remotehost+' : '+tcpclient1.remoteport); [color=lime]// vei fi avertizat cand te`ai conectat, cu acest mesaj[/color]tcpclient1.sendln('Conectat');9. 1click pe tcpclient, ne ducem la events si la OnDisconnect punem acest codshowmessage('Deconectat'); [color=lime]// vei fi avertizat cand te`ai deconectat[/color]10. 2click pe button2 si punem acest codif edit3.gettextlen > 0 then tcpclient1.sendln(edit3.text) else showmessage('Scrie un mesaj');Server1. Adaugam pe form un tcpserver2. Adaugam pe server un memo3. 2click pe tcpserver, stergem cuvantul "begin" si punem acest codvars: string;begins := tcpserver1.receiveln;while s <> '' then begins := tcpserver1.receiveln;memo1.lines.add(s); [color=lime]// adaugam in memo textul primit de la client[/color] end;end;4. 1click pe tcpserver si din objectinspector modificam urmatoarele:Active: trueLocalport: 2323 Quote
PePe Posted October 30, 2009 Report Posted October 30, 2009 Frate, unde gasesc TcpClient si TcpServer...le'am cautat in tot Delphi'ul Quote
virusz Posted October 30, 2009 Report Posted October 30, 2009 Component-> Install Packages-> Add (/bin/dclsockets70.bpl). sauvezi: Indy Quote
PePe Posted October 31, 2009 Report Posted October 31, 2009 am bagat TAB'ul Internet, dar nu am TCP, am Socket Client si server Quote