flat assembler
Message board for the users of flat assembler.
Index
> Windows > WinSock |
Author |
|
vbVeryBeginner 13 Jan 2006, 09:34
you could check tomasz's Quetannon example which using winsock.
http://flatassembler.net/examples.php Demonstration of using WinSock library to make TCP/IP connections. Written by Tomasz Grysztar. |
|||
13 Jan 2006, 09:34 |
|
velox 13 Jan 2006, 21:31
FrozenKnight,
the FD_CLR(s,*set) removes a socket descriptor from the given fd_set structure. i'll try to explain it with a little example. let's say we've connected to a smtp server and we want to know if data can be read from "our" smtp_socket. first we set up a fd_set "structure" smtp_sock dd 0 ; here we put in the the connected socket read_fds: ;read fd_set socket_count dd 0 ;fd_count socket_array dd FD_SETSIZE dup(0) ;fd_array next, we should "set" our socket in the read_fds structure. in C we could use FD_SET(smtp_sock,&read_fds) in asm this translates into something like: mov [socket_count],1 ; one socket (smtp_sock) mov eax,[smtp_sock] mov [socket_array],eax ; put it into structure [the FD_CLR(smtp_sock,&read_fds) macro searches the socket_array for smtp_sock,clears it from the array and decrements the fd_count value.] next we call select: xor ebx,ebx push ebx ; optional pointer to a timeout structure push ebx ;except_fds push ebx ;write_fds push read_fds ; we're only interested if we can read data ; write_fds and except_fds pointers are zeroed therefore push ebx call select in our case eax should now be 1 if smtp_sock is ready for reading .... i hope this snippet helped you. (at least a lil bit ) regards, velox |
|||
13 Jan 2006, 21:31 |
|
FrozenKnight 14 Jan 2006, 17:01
Yes, i think that does thank you.
While QnetAnon helps a little i dont think it's what i'm after. i'm trying to write a server which can accept over 1000 connections. and QnetAnon only supports one connection. |
|||
14 Jan 2006, 17:01 |
|
okasvi 15 Jan 2006, 03:48
have you read tutorial at www.madwizard.org ?
btw. i find it strange that last part of tutorial is Quote: 12. Conclusion maybe he didnt have time/skill to go further than that _________________ When We Ride On Our Enemies support reverse smileys |: |
|||
15 Jan 2006, 03:48 |
|
FrozenKnight 15 Jan 2006, 11:01
First off i am learning from much more advanced documentation. Second I checked out that site earlyer. i'm not really intrested in blocking sockets becasue they dont support mupital connections very well if at all. Also i already know how to manage the efect that he mentione in his side note for the next turt.
the thing you need to remember when you look at that is that there are 2 types of data Variable length and Fixed length. Fixed length is easy because you can simply set up a struct for it and copy the data in as is. variable length is a little more complex becasue you have to either set a delimiter or know the length before you begin copying it. i personaly perfer the second method because it's a little faster but and doesn't require you to eliminate certan charicter sets from your strings. I'm not a beginner programmer just begginging at sockets. give me a little credit. and i can convert between C and asm when i know what is going on (some code can be hard to understand even though it does something simple) which is why velox post was most helpfull. |
|||
15 Jan 2006, 11:01 |
|
FrozenKnight 17 Jan 2006, 09:32
just for anyone curious that wants to use the fd_set macro's in fasm. i created these functions (i updated them with macros to clean up code a bit but they basicaly act the same way.)
Code: ;fd_set macros FD_SETSIZE = 64 struct fd_set fd_count dd ? fd_array dd FD_SETSIZE dup (?) ends ;helper macros macro FD_CLR fd, set { push set push fd call pFD_CLR } macro FD_SET fd, set { push set push fd call pFD_SET } macro FD_ZERO set { push set call pFD_ZERO } macro FD_ISSET fd, set { push set push fd call pFD_ISSET } ;fd_set functions proc pFD_CLR fd, set push esi push ecx push ebx mov ebx, [set] mov esi, [fd] xor ecx, ecx .oloop: cmp ecx, [ebx+fd_set.fd_count] jge .cleanup cmp esi, [ebx+ecx*4+fd_set.fd_array] jz .iloop inc ecx jmp .oloop .iloop: mov eax, [ebx+ecx*4+fd_set.fd_array+4] mov [ebx+ecx*4+fd_set.fd_array], eax inc ecx cmp ecx, [ebx+fd_set.fd_count] jl .iloop dec [ebx+fd_set.fd_count] .cleanup: pop ebx pop ecx pop esi ret endp proc pFD_SET fd, set push ebx mov ebx, [set] mov eax, [ebx+fd_set.fd_count] cmp eax, FD_SETSIZE jge .cleanup push [fd] pop [eax*4+ebx+fd_set.fd_array] inc [ebx+fd_set.fd_count] .cleanup: pop ebx ret endp proc pFD_ZERO set mov eax, [set] mov [eax+fd_set.fd_count], 0 ret endp proc pFD_ISSET fd, set push esi push ecx push ebx mov ebx, [set] mov esi, [fd] xor ecx, ecx xor eax, eax .oloop: cmp ecx, [ebx+fd_set.fd_count] jge .cleanup cmp esi, [ebx+ecx*4+fd_set.fd_array] jz .found inc ecx jmp .oloop .found: inc eax .cleanup: pop ebx pop ecx pop esi ret endp i know i could probably have just created better macros but i'm not very familar with the macro system yet. |
|||
17 Jan 2006, 09:32 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.