View Full Version: TCP usefull Functions

meos32 >>Useful Routines >>TCP usefull Functions


Don- 03-21-2006
TCP usefull Functions
I didn't make this routine, but anyway it was hard to find for me, I remember that was made by Endre ;ip to string conversion by Endre: ; esi - 0 ended string to convert ; edx - result convert_ip_str_to_int: xor edx, edx; result xor eax, eax; current character xor ebx, ebx; current byte .outer_loop: shl edx, 8 add edx, ebx xor ebx, ebx .inner_loop: lodsb test eax, eax jz .finish cmp al, '.' jz .outer_loop sub eax, '0' imul ebx, 10 add ebx, eax jmp .inner_loop .finish: shl edx, 8 add edx, ebx ret ;eax - int to convert ; edi - buffer the string is to be written to convert_int_to_ip_str: xor ebx, ebx mov cl, 3 .outer_loop: shld eax, edx, 8 shl edx, 8 mov bl, 2 .inner_loop: aam add al, '0' mov [edi+ebx], al mov al, ah dec bl jns .inner_loop dec cl js .finish mov byte [edi+3], '.' add edi, 4 jmp .outer_loop .finish: ret EDITED TO ADD THE "xor ebx,ebx" at the beginning of convert_int_to_ip_str:"

hidnplayr- 03-22-2006

thanks this will be usefull for my MSN project when server requests to join another server :p

Theorizer- 03-22-2006

Attention! There is a little bug in function convert_int_to_ip_str: instead of mov bl, 2 you should write mov ebx, 2 Or at the beginning of the function you should write xor ebx, ebx T.

Don- 03-22-2006

thanks, I edited the original post :)

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.