* * *

Author Topic: Socket server program no response when using fprecv?  (Read 1050 times)

Jonvy

  • New member
  • *
  • Posts: 22
Socket server program no response when using fprecv?
« on: April 12, 2018, 02:30:52 pm »
I write a program to receive data from socket client and display the data in edit control.
First time when I receive data, the program works well.

But for 2nd time, when I click 'receive text', the program will not work,and Windows show no response.

I can not find the reason, can any one help me?

code like this:

procedure TForm1.BtnTxtRecvClick(Sender: TObject);
var
  ReceLen,i:integer;//Receive Length;
  BlockBuf:array[0..BlockLen-1] of Byte;//Buffer Zone;
  RecvSocket:longint;
  ra:SOCKADDR_IN;//define SOCKADDR_IN var
  ra_len:integer;//ra length
begin
  ra_len:=sizeof(ra);
  //Waiting connection from client
  RecvSocket:=fpaccept(serverSocket,@ra,@ra_len);

  //Receive Data
  if RecvSocket<>-1 then
  begin
    ReceLen:=fprecv(RecvSocket,@BlockBuf[0],BlockLen,0);

    i:=0;
    while i<ReceLen do
      begin
      EdtReceive.Text:=EdtReceive.Text+Chr(BlockBuf);
      Inc(i,1);
      end;

  fpShutDown(RecvSocket,2);
  closeSocket(RecvSocket);
  end;
end; 

I attach all files here.
When using it,1st click but 'Listen', then after receiving data from socket,click button 'Receive Test'.


Thaddy

  • Hero Member
  • *****
  • Posts: 6880
Re: Socket server program no response when using fprecv?
« Reply #1 on: May 12, 2018, 03:56:28 pm »
Stop spamming.
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus