진짜루 급한 질문입니당...ㅠ.ㅠ
에러내용입니다..
Exeception ESocketError in Module Rabbit_server.exe at 004D2F9
Window Socket Error: (-1), On API 'WSACleanup'.
이 에러가 대체 머지영??..ㅠ.ㅠ
알 수가 없습니다...
프로그램을 실행시키고 클라이언트와 접속후...연결을 끊든 안끊든...
서버프로그램을 close 시키면 저 에러가 뜨네여..
고수 열분들...제발 좀 알려주세영...
아래는 소스입니다..
unit Main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ScktComp, ComCtrls, Db, DBTables, Winsock;
type
TFrm_Main = class(TForm)
TreeView1: TTreeView;
Servers: TServerSocket;
Memo1: TMemo;
Btn_Listen: TButton;
Btn_Disconnect: TButton;
Database1: TDatabase;
Query1: TQuery;
procedure Btn_ListenClick(Sender: TObject);
procedure ServersListen(Sender: TObject; Socket: TCustomWinSocket);
procedure ServersAccept(Sender: TObject; Socket: TCustomWinSocket);
procedure ServersClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ServersClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ServersClientError(Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent; var ErrorCode: Integer);
procedure ServersClientRead(Sender: TObject; Socket: TCustomWinSocket);
procedure ServersClientWrite(Sender: TObject;
Socket: TCustomWinSocket);
procedure ServersGetSocket(Sender: TObject; Socket: Integer;
var ClientSocket: TServerClientWinSocket);
procedure ServersGetThread(Sender: TObject;
ClientSocket: TServerClientWinSocket;
var SocketThread: TServerClientThread);
procedure ServersThreadEnd(Sender: TObject;
Thread: TServerClientThread);
procedure ServersThreadStart(Sender: TObject;
Thread: TServerClientThread);
procedure Btn_DisconnectClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_Main: TFrm_Main;
id,pwd,loginfo: String;
currlogin : boolean;
implementation
{$R *.DFM}
procedure TFrm_Main.Btn_ListenClick(Sender: TObject);
begin
If Not servers.Active then
begin
Servers.Open;
end;
end;
procedure TFrm_Main.ServersListen(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.Lines.Add('[OnListen]');
end;
procedure TFrm_Main.ServersAccept(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.Lines.Add('[OnAccept]');
end;
procedure TFrm_Main.ServersClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.Lines.Add('[OnClientConnect]');
end;
procedure TFrm_Main.ServersClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.Lines.Add('[OnClientDisconnect]');
currlogin := false;
end;
procedure TFrm_Main.ServersClientError(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
memo1.Lines.Add('[OnClientError]');
end;
procedure TFrm_Main.ServersClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.Lines.Add('[OnClientRead]');
loginfo := socket.receivetext;
id := copy(loginfo, 1, pos('/', loginfo)-1);
pwd := copy(loginfo, pos('/', loginfo)+1, (length(loginfo))-(length(id)+1) );
with query1 do
begin
close;
sql.Clear;
sql.Add('select id, name, Password from test123 where id = :id2');
ParamByName('id2').asstring := id;
open;
Last;
First;
end;
If query1.RecordCount <= 0 then
begin
servers.Socket.Connections[0].SendText('zero');
end
else
begin
If query1.Fields[2].Value = pwd then
begin
servers.Socket.connections[0].SendText('ok/' + query1.fields[1].value);
currlogin := true;
end
else
begin
servers.Socket.connections[0].sendtext('nopwd');
end;
end;
end;
procedure TFrm_Main.ServersClientWrite(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.Lines.Add('[OnClientWrite]');
end;
procedure TFrm_Main.ServersGetSocket(Sender: TObject; Socket: Integer;
var ClientSocket: TServerClientWinSocket);
begin
memo1.Lines.Add('[OnGetSocket]');
end;
procedure TFrm_Main.ServersGetThread(Sender: TObject;
ClientSocket: TServerClientWinSocket;
var SocketThread: TServerClientThread);
begin
memo1.Lines.Add('[OnGetThread]');
end;
procedure TFrm_Main.ServersThreadEnd(Sender: TObject;
Thread: TServerClientThread);
begin
memo1.Lines.Add('[OnThreadEnd]');
end;
procedure TFrm_Main.ServersThreadStart(Sender: TObject;
Thread: TServerClientThread);
begin
memo1.Lines.Add('[OnThreadStart]');
end;
procedure TFrm_Main.Btn_DisconnectClick(Sender: TObject);
begin
If currlogin = true then
servers.Socket.Connections[0].SendText('disconnect');
If servers.Active then
servers.Close;
end;
procedure TFrm_Main.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Wsasetlasterror(-1);
Wsagetlasterror;
If servers.active then
servers.Close;
end;
end.