Delphi TCP/IP idtcpserver1 instance 1

Source: Internet
Author: User

Unit unit1;

Interface

Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, idbasecomponent, idcomponent, idtcpserver, stdctrls;

Type
Tform1 = Class (tform)
Idtcpserver1: tidtcpserver;
Button1: tbutton;
Edit1: tedit;
Edit2: tedit;
Label1: tlabel;
Label2: tlabel;
Button2: tbutton;
Procedure button1click (Sender: tobject );
Procedure idtcpserver1execute (athread: tidpeerthread );
Procedure button2click (Sender: tobject );

Private
{Private Declarations}
Public
{Public declarations}
End;

VaR
Form1: tform1;

Implementation

{$ R *. DFM}

Procedure tform1.button1click (Sender: tobject );
Begin
Idtcpserver1.bindings. Clear;
Idtcpserver1.bindings. Add. IP: = '192. 168.1.126 ';
Idtcpserver1.bindings. Add. Port: = 168;
Idtcpserver1.active: = true;
If idtcpserver1.active then
// Showmessage ('server running ')
Edit1.text: = 'server running'
Else
Edit1.text: = 'server stop'

End;

Procedure tform1.idtcpserver1execute (athread: tidpeerthread );

VaR
M_string: string;
Begin
M_string: = athread. Connection. readln ();

If m_string = 'begin' then
Begin
Athread. Connection. writeln ('I want to upload the text! ');
Edit1.text: = 'transfer preparation ';
Exit;
End;
If m_string = 'end' then
Begin
Edit1.text: = 'transfer termination ';
Exit;
End;
If m_string = 'qx' then
Begin
Edit1.text: = 'cancel transfer ';
Exit;
End;
End;


Procedure tform1.button2click (Sender: tobject );
Begin
Idtcpserver1.destroy;

Edit1.text: = 'server stop ';
End;

End.

Source code download: http://download.csdn.net/source/1261880

Delphi TCP/IP idtcpserver1 instance 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.