클라이언트와 서버 연결은 되었는데 클라이언트에서 서버로 데이타가 안넘어갑니다.
왜 그런지 정말 모르겠습니다
고수님들 답변 부탁드립니다
소스는 다음과 같습니다.
////// 정의된 레코드 ////////////////////////////////////
//서버 헤더
type
TSERVER_HEADER = record
Identification : array [0..3] of char;
Version : array [0..3] of char;
Session : array [0..3] of char;
Kind : array [0..3] of char;
Option : array [0..3] of char;
Length : Integer;
end;
//사용자 인증 요청
type
TSER_SEND_USER = record
TSERVER_HEADER : TSERVER_HEADER;
Data : array [0..1023] of Char;
end;
//사용자 인증 응답
type
TSER_RECEIVE_USER = record
//TSER_RES_USER = record
TSERVER_HEADER : TSERVER_HEADER;
Data : array [0..1023] of Char;
end;
///////// 서버에서 구동 부분 ////////////////////////////////////////
procedure TfrmServer.Button1Click(Sender: TObject);
begin
ServerSocket.Close;
ServerSocket.Port := StrToInt(REG_READ(REG_NETWORK,'ServerPort'));
try
ServerSocket.Active := True;
except
on E:Exception do
begin
Showmessage('네트웍이 연결되지 않았습니다.'+#13+#13+E.Message);
exit;
end;
end;
end;
///////// 서버에서 데이타 받는 부분/////////////////////////////////
procedure TfrmServer.ServerSocketClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
//recvLength : integer;
Len : Integer;
SER_SEND_USER : TSER_SEND_USER ;
SER_RECEIVE_USER : TSER_RECEIVE_USER;
SendDate : String;
begin
ZeroMemory(@SER_SEND_USER , SizeOf(SER_SEND_USER ));
Len := Socket.ReceiveLength;
//Socket.ReceiveBuf(SER_SEND_USER , recvLength);
Socket.ReceiveBuf(SER_SEND_USER, Socket.ReceiveLength);
with SER_SEND_USER do
begin
//받은 Data
if (TSERVER_HEADER.Kind = #100) and
(TSERVER_HEADER.Length <> 0) then
begin
Memo1.Lines.Text := SER_RECEIVE_USER.Data;
SendDate := '<ACE_TR100><RESPONES><RIGHT>'+ComboBox1.Text+'</RIGHT></RESPONES></ACE_TR100>';
ZeroMemory(@SER_RECEIVE_USER, sizeof(SER_RECEIVE_USER));
with SER_RECEIVE_USER do
begin
TSERVER_HEADER.Identification := 'EAMP';
TSERVER_HEADER.Version := '1.00';
TSERVER_HEADER.Session := #2;
TSERVER_HEADER.Kind := #100;
TSERVER_HEADER.Option := #10;
StrPCopy(SER_RECEIVE_USER.Data, SendDate);
TSERVER_HEADER.Length := SizeOf(SER_RECEIVE_USER.Data);
end;
ServerSocket.Socket.Connections[0].SendBuf(SER_RECEIVE_USER, SizeOf(SER_RECEIVE_USER));
end;
end;
end;
///////// 클라이언트에서 연결 부분 ///////////////////////////////////
procedure TfrmLogin.FormCreate(Sender: TObject);
begin
ClientSocket.Port := StrToInt(REG_READ(REG_NETWORK,'ServerPort'));
ClientSocket.Address := UserInfo.User_Ip;
ClientSocket.Active := True;
end;
///////// 클라이언트에서 데이타 서버로 보내는 부분 ///////////////////
var
//recvLength : integer;
SER_SEND_USER : TSER_SEND_USER;
SER_RECEIVE_USER : TSER_RECEIVE_USER;
SendDate : String;
begin
ZeroMemory(@SER_SEND_USER, SizeOf(SER_SEND_USER));
//ClientSocket.Socket.ReceiveBuf(SER_SEND_USER, recvLength);
ClientSocket.Socket.ReceiveBuf(SER_SEND_USER, ClientSocket.Socket.ReceiveLength);
UserInfo.User_Id := edtUser.text;
UserInfo.User_Pwd := edtPass.text;
//UserInfo.User_Power := ;
SendDate := '<ACE_RE100><REQUEST><IP>'+userInfo.User_Ip+'</IP>'+
'<ID>'+edtUser.Text+'</ID>'+
'<PASSWORD>'+edtPass.Text+'</PASSWORD></REQUEST></ACE_RE100>';
with SER_SEND_USER do
begin
TSERVER_HEADER.Identification := 'EAMP';
TSERVER_HEADER.Version := '1.00';
TSERVER_HEADER.Session := #1;
TSERVER_HEADER.Kind := #100;
TSERVER_HEADER.Option := #0;
StrPCopy(SER_SEND_USER.Data, SendDate);
TSERVER_HEADER.Length := SizeOf(SER_SEND_USER.Data);
ClientSocket.Socket.SendBuf(SER_SEND_USER, SizeOf(SER_SEND_USER))
end;
end;