DelphiµÄSocket±à³ÌÒª·Ö¼¸²½£¿
DelphiµÄSocket±à³ÌÒª·Ö¼¸²½£¿
2008-12-20 02:03:24
¡¡±êÇ©£ºDelphi Socket ±à³Ì¡¡¡¡¡¡[ÍÆË͵½¼¼ÊõȦ]
ClientSocket ºÍServerSocket
¼¸¸öÖØÒªµÄÊôÐÔ:
1.clientºÍserver¶¼ÓÐportÊôÐÔ£¬ÐèÒªÒ»Ö²ÅÄÜ»¥ÏàͨÐÅ
2.clientÓÐAddressÊôÐÔ,ʹÓÃʱÌîд¶Ô·½(server)µÄIPµØÖ·
¼¸¸öÖØÒªµÄʼþ:
client: OnReadʼþ£¬µ±clientÊܵ½³å»÷ÏûϢʱÔÚOnReadʼþÖпÉÒÔ»ñµÃserver·¢Ë͹ýÀ´ÏûÏ¢¡£
Server: OnClientReadʼþ£¬ÓëÉÏÊöclientµÄ×÷ÓÃÏàͬ
·¢ËÍÐÅÏ¢£º
clienʹÓÃSocketClient1.Socket.SendBuf(charÀàÐ͵ÄÊý×é,ÐÅÏ¢³¤¶È);
serverʹÓÃSocketServer1.Socket.Connection[0].SendBuf(charÀàÐ͵ÄÊý×é,ÐÅÏ¢³¤¶È);
½ÓÊÕÐÅÏ¢
clienʹÓÃSocketClient1.Socket.ReceiveBuf(charÀàÐ͵ÄÊý×é,ÐÅÏ¢³¤¶È);
serverʹÓÃSocketServer1.Socket.Connection[0].ReceiveBuf(charÀàÐ͵ÄÊý×é,ÐÅÏ¢³¤¶È);
ʹÓÃsockets
Socket ¿Ø¼þÈÃÄ㽨Á¢Ò»¸öÀûÓÃTCP/IPºÍÓйصÄÐÒéÓëÆäËûϵͳ½øÐÐͨÐŵÄÓ¦Óá£Ê¹ÓÃSockets£¬ÄãÄܹ»¶ÁºÍдͨ¹ýËüÁ¬½ÓµÄÆäËû»úÆ÷£¬¶ø²»Óõ£ÐÄʵ¼ÊµÄÍøÂçÈí¼þµÄÏà¹Øϸ½Ú¡£SocketsÌṩ»ùÓÚTCP/IPÐÒéµÄÁ¬½Ó¡£³ý´ËÒÔÍ⻹ÄܺܺõŤ×÷£¬ÔÚÆäËûÏà¹ØµÄÐÒé¡£
Delphi ÌṩÄãдÍøÂç·þÎñÆ÷»ò¿Í»§Ó¦ÓóÌÐòÈ¥¶ÁºÍдÆäËûµÄϵͳ¡£Ò»¸ö·þÎñ»ò¿Í»§³ÌÐòͨ³£×¨×¢ÓÚÒ»¸öµ¥Ò»µÄ·þÎñÈ糬Îı¾´«ËÍÐÒ飨HTTP)»òÎļþ´«ÊäÐÒé (FTP)¡£Ê¹ÓÃserver sockets,Ò»¸öÓ¦ÓóÌÐò¿ÉÒÔÌṩÕâЩ·þÎñÖеÄÒ»¸öÈ¥Á¬½ÓÒ»¸öÏ£ÍûʹÓ÷þÎñµÄ¿Í»§³ÌÐò¡£Client socketsÔÊÐíÒ»¸öÓ¦ÓÃʹÓÃÕâЩ·þÎñÖеÄÒ»¸öÈ¥Á¬½ÓÌṩÕâ¸ö·þÎñµÄ·þÎñÓ¦Ó
Ïà¹ØÎĵµ£º
Windows ÏÂÒ»¸öµäÐ͵ÄÌØÕ÷¾ÍÊǶàÈÎÎñ£¬ÎÒÃÇ¿ÉÒÔͬʱ´ò¿ª¶à¸ö´°¿Ú½øÐвÙ×÷£¬Ò²¿ÉÒÔͬʱÔËÐгÌÐòµÄ¶à¸öʵÀý£¬±ÈÈç¿ÉÒÔ´ò¿ªÐí¶à¸ö×ÊÔ´¹ÜÀíÆ÷½øÐÐÎļþµÄÒƶ¯¸´ÖƲÙ×÷¡£µ«ÓÐʱ³öÓÚijÖÖ¿¼ÂÇ£¨±ÈÈ簲ȫÐÔ£©£¬ÎÒÃÇÒª×ö³öһЩÏÞÖÆ£¬ÈóÌÐòÖ»Äܹ»ÔËÐÐÒ»¸öʵÀý¡£ÔÚDelphi±à³ÌÖУ¬±ÊÕß×ܽá³öÁËÒÔϼ¸ÖÖ·½·¨£º
¡¡¡¡Ò»¡¢ ²éÕÒ´°¿Ú·¨
¡¡¡ ......
¹ý³ÌÎÞ·µ»ØÖµ£¬º¯ÊýÓзµ»ØÖµ¡£
procedure MyProc(m,n : Integer; o : String; p : Single = 2.5; q : String = 'Delphi');
ÈçÉÏÀýËùʾ£¬¹ý³ÌÉùÃ÷ºÍ¶¨ÒåÖУ¬¶à¸ö²ÎÊýÊÇÓ÷ֺŸô¿ªµÄ£¬µ«ÔÚµ÷ÓÃʱÊÇÓöººÅ¸ô¿ªµÄ ¡£eg£º
......
delphiµ÷ÓÃÑ¡ÔñĿ¼¶Ô»°¿ò
¾³£¼ûÍøÉÏÓÐÈËÎÊÑ¡ÔñĿ¼¶Ô»°¿òµÄ¿Ø¼þ£¬ÆäʵֻÓÃÒ»¸öº¯Êý¾Í¿ÉÒÔʵÏÖ¡£
×¢ÒâÒýÓÃ Filectrl µ¥Ôª
use Filectrl;
procedure TForm1.Button1Click(Sender: TObject);
var
Dir: String;
begin
SelectDirectory('Select a directory', '', Dir);
ShowMessage(Dir);
end; ......
ÓÃVC++6.0±àдÁËÒ»¸ö¼òµ¥µÄdll£¬ÀïÃæ°üº¬Ò»¸ö¼õ·¨º¯Êýsubtract(int a,int b)£¬DllÃüÃûΪff.Dll
´úÂëÈçÏ£º
1.ff.cpp:
// ff.cpp : Defines the entry point for the DLL application.
//
#include "StdAfx.h"
#include "ff.h"
BOOL APIENTRY DllMain( HANDLE hModule,
......
Ò»¡¢Formatº¯ÊýµÄÓ÷¨
FormatÊÇÒ»¸öºÜ³£Óã¬È´ÓÖËƺõºÜ·³µÄ·½·¨£¬±¾ÈËÊÔͼ¶ÔÕâ¸ö·½·¨µÄ°ïÖú½øÐÐһЩ·Ò룬ÈÃËüÓÐÒ»¸öÍêÕûµÄ¸Åò£¬ÒÔ¹©´ó¼Ò²éѯ֮Óãº
Ê×ÏÈ¿´ËüµÄÉùÃ÷£º
function Format(const Format: string; const Args: array of const): string; overload;
ÊÂʵÉÏFormat·½·¨ÓÐÁ½¸öÖÖÐÎʽ£¬ÁíÍâÒ»ÖÖÊÇÈý¸ö²ÎÊýµÄ£¬Ö ......