Home > Back-end >  IdUDP error, guidance
IdUDP error, guidance

Time:09-30

Just learning Delphi, refer to a code on the net, want to write an example of a UDP send pictures, the following code
Var
Filestream: TMemoryStream;
The begin
Filestream:=TMemoryStream. Create;
Savetojpgstream (filestream);//the file to the filestream
Idpsrvr1. SendBuffer (* 127.0.0.1 *, 8009, filestream filestream. Size);//run to go wrong here, show socketerror 10014
Filestream. Free
end;
Please guide, why is this so??? Where is wrong?????? The great spirit guide, or a great god can reference the UDP send demo pictures not
Using Delphi7 indy 9

CodePudding user response:

Indeed no one...

CodePudding user response:

The definition of didn't see you ClientAddrLen forehead?

ClientAddrLen=sizeof (ClientAddr);

CodePudding user response:

Length must be specified, initialize the correct values,
Otherwise is prone to 10014

CodePudding user response:

reference dongyonggan reply: 3/f
length must be specified, initialize the correct values,
Otherwise it's easy to have a 10014

Mean the size of the send is the specified value, cannot be filestream. Size?

CodePudding user response:

refer to the second floor yangb0803 response:
didn't see you ClientAddrLen define the forehead?

ClientAddrLen=sizeof (ClientAddr);
indyUDP also need to specify this?

CodePudding user response:

Var
Filestream: TMemoryStream;
The begin
Filestream:=TMemoryStream. Create;
Savetojpgstream (filestream);//the file to the filestream
Filestream. Postion:=0;
Idpsrvr1. SendBuffer (* 127.0.0.1 *, 8009, filestream filestream. Size;
Filestream. Free
end;
  • Related