procedure TRealMessengerX.SendIdentity; //验证身份
var
LoginTime: Integer;
CBLogin: TCBLogin;
Buffer: array[1..2048] of char;
StrHttpProxySend, StrHttpProxyRecive: string;
begin
if ClientTCP.Connected=false then //窗体自带TCP控件连接没有打开的情况下……
begin
// showmessage(trim(SystemSetForm.EDHostName.Text));
// showmessage(SystemSetForm.EDHostName.Text);
if inet_addr(PChar(HostIP))=INADDR_NONE then
ClientTCP.Host:=HostName
else
ClientTCP.Host:=HostIP;
ClientTCP.Port:=ServerPort;
{ClientTCP.Host := trim(SystemSetForm.EDHostName.Text);
ClientTCP.Port := StrToInt(SystemSetForm.EDHostName.Text);}
try
MConnect.Caption := '取消登录(&I)';
Gauge.Progress := 0;
PBLogin.Visible := True;
LblLoging.Caption := '正在连接...';
LblLoging.Visible := True;
LblCancelLogin.Visible := True; if ProxyCategory <> pcHTTP then //代理种类如果不是HTTP,为真
begin
IdSocksInfo1.Version := TSocksVersion(ProxyCategory);
IdSocksInfo1.Host := ProxyAddress;
IdSocksInfo1.Port := ProxyPort;
if ProxyUsername = '' then
begin
IdSocksInfo1.Authentication := saNoAuthentication;
end
else
begin
IdSocksInfo1.Authentication := saUsernamePassword;
IdSocksInfo1.Username := ProxyUsername;
IdSocksInfo1.Password := ProxyPassword;
end; LoginTime := 0;
while LoginTime < 3 do
try
ClientTCP.Connect(8000); //TCP尝试连接三次
break;
except
Inc(LoginTime);
end;
end
else
begin
IdSocksInfo1.Version := svNoSocks;
StrHttpProxySend := Format('CONNECT %s:%d HTTP/1.0'#$d#$a#$d#$a + 'Host %s'#$d#$a, [ClientTCP.Host, ClientTCP.Port, ClientTCP.Host]);
ClientTCP.Host := ProxyAddress;
ClientTCP.Port := ProxyPort;
ClientTCP.Connect(8000);
ClientTCP.Write(StrHttpProxySend); //写入字符HTTP代理发送字符串中
StrHttpProxyRecive := ClientTCP.ReadLn; //(EOL); 读取信息,保存至HTTP代理接受字符串中
ClientTCP.ReadLn;
ClientTCP.ReadLn;
if Copy(StrHttpProxyRecive, 1, 12) <> 'HTTP/1.0 200' then
ClientTCP.Disconnect;
end; except
end; if not ClientTCP.Connected then
begin
ClientLogout;
CoolTrayIcon.ShowBalloonHint('连接失败', '未能连接至服务器,请检查网络设置!', bitError, 10);
exit;
end; ClientHandleThread := TClientHandleThread.Create; // 窗体TCP控件如果连接没有打开的情况下。激活线程开始工作
ClientHandleThread.FreeOnTerminate := True; //线程如果推出,释放所有资源
ClientHandleThread.Resume; //唤醒 if ClientTCP.Connected = False
end;//既然都没有保持连接,为什么还要用一个线程来读取服务器信息? CBLogin.LoginName := LoginName; //用户名
CBLogin.Password := Password; //密码
CBLogin.State := LoginState; //状态:联机
CBLogin.LocalIP := GetHostIP(''); //本机IP
CBLogin.LocalPort := ClientTCP.Socket.Binding.Port; //本机端口
CBLogin.HaveAudioDevice := HaveAudioDevice;
CBLogin.HaveVideoDevice := HaveVideoDevice;
CBLogin.MACNO := MACNO;
CBLogin.Version := 40000; //版本
Buffer[1] := skLogin;
CopyMemory(@Buffer[2], @CBLogin, SizeOf(CBLogin));
ClientTCP.Socket.Send(Buffer, SizeOf(CBLogin) + 1); //将登录信息,用TCP方式,发送至登录服务器;
LblMyState.Caption := '正在登录...';
end;
if ClientTCP.Connected=false then//这一句,既然没有保持连接,为什么还要用一个线程来读取服务器信息?
解决方案 »
- delphi---dbgrid批量插入到sql中
- 在Delphi下使用 DevExpress 控件的朋友,希望在此留下E-Mail或QQ,诚心交流、共同提高。
- 有关树的问题,请各位改一下
- 数据库的问题,十万火急!!!
- 看一下这个"Record not found or changed by another user"问题,和其他人的不一样.
- 请问怎么实现delphi客户端程序的及时检测,下载新版本更新自身呢?你们又什么怎么做的呢?讨论一下好吗。。
- 散分!!第一个程序在天空提交通过!!
- 如何在报表中打印多张图片。
- 特急!一个sql语句的问题!
- 如何判断listview控件点击复选框时的事件?
- 请教:delphi有么有精确到毫秒的时间戳?
- FastReport分组打印问题
ClientHandleThread := TClientHandleThread.Create; // 窗体TCP控件如果连接没有打开的情况下。激活线程开始工作
ClientHandleThread.FreeOnTerminate := True; //线程如果推出,释放所有资源
ClientHandleThread.Resume; //唤醒 if ClientTCP.Connected = False
end;//既然都没有保持连接,为什么还要用一个线程来读取服务器信息?
ClientHandleThread := TClientHandleThread.Create; // 窗体TCP控件如果连接没有打开的情况下。激活线程开始工作
ClientHandleThread.FreeOnTerminate := True; //线程如果推出,释放所有资源
ClientHandleThread.Resume; //唤醒 if ClientTCP.Connected = False
end;//既然都没有保持连接,为什么还要用一个线程来读取服务器信息?
所以线程开启 啊。