與shf301提示,這是我得到它與
工作的代碼我創建了一個新的TIdIPMCastClient
TIdReUseIPMCastClient = class(TIdIPMCastClient)
private
procedure SetReUseAddr(InBinding: TIdSocketHandle; const Value: boolean);
protected
function GetBinding: TIdSocketHandle; override;
public
end;
添加的程序
procedure TIdReUseIPMCastClient.SetReUseAddr(InBinding: TIdSocketHandle; const Value: boolean);
var
tempi: integer;
begin
if Assigned(InBinding) and InBinding.HandleAllocated then
begin
tempi := iif(Value, 1, 0);
InBinding.SetSockOpt(Id_SOL_SOCKET, Id_SO_REUSEADDR, PChar(@tempi), SizeOf(tempi));
end;
end;
複製GetBinding來自TIdIPMCastClient的代碼,並在綁定之前添加SetReUseAddr
Bindings[i].AllocateSocket(Id_SOCK_DGRAM);
SetReUseAddr(Bindings[i], True);
Bindings[i].Bind;
非常好,SO_REUSEADDR這就是我需要的提示 – 2010-04-14 06:18:33
在mac OSX上,我必須添加: 'sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEPORT,True)' – 2010-05-21 00:25:13