Einzelnen Beitrag anzeigen

Astat

Registriert seit: 2. Dez 2009
Ort: München
320 Beiträge
 
Lazarus
 
#6

AW: Bluetooth Server Win32 API

  Alt 13. Sep 2010, 14:59
..mal nen Blick drüber werfen.

Hi Brainstalker, als Minimum Sample sollte noch folgendes implementiert werden.

Delphi-Quellcode:
var
  ...
  name: SOCKADDR_BTH;
  addrlen: integer;
  ClientSocket: TSocket;
begin
  iResult := WSAStartup($0020, @wsaD);
.....

//----------------------
// Listen for incoming connection requests
// on the created socket

  if (listen(ListenSocket, SOMAXCONN) = SOCKET_ERROR) then
    ShowMessage('Error listening on socket.');

  addrlen := SizeOf(name);
  while ServerRunning do begin
    ClientSocket := Accept(ListenSocket, @name, @addrlen);
    if (ClientSocket <> INVALID_SOCKET) then begin
      cbRcv := Recv(ClientSocket, szBuf[0], WSOCK_READ_BUFFER_SIZE, 0);
      if (cbRcv = 0) or (cbRcv = SOCKET_ERROR) then EXIT;
      .... loop
      ret := ioctlsocket(ClientSocket, FIONREAD, cbRead);
      result := Send(ASocket, sSendData[1], Length(sSendData), 0);
      done....
    end;
  end;

  ShowMessage('Listening on socket...');
  WSACleanup();
  exit;

end;
lg. Astat
Lanthan Astat
06810110811210410503210511511603209711003210010110 9032084097103
03211611111604403209711003210010110903210010510103 2108101116122
11610103209010110510810103206711110010103210511003 2068101108112
10410503210310111509910411410510109810111003211910 5114100046
  Mit Zitat antworten Zitat