Re: Port binding under linux in ASM
- From: Chuck Crayne <ccrayne@xxxxxxxxxx>
- Date: Sat, 19 Apr 2008 12:28:06 -0700
On Sat, 19 Apr 2008 11:01:19 -0700 (PDT)
tin.cans.and.string@xxxxxxxxx wrote:
I am having the *damndest* time finding asm-oriented documentation on
linux syscalls in general, but port binding in particular.
For everything but port binding, you can download a demonstration
graphics game from my web site. For port binding in particular, here is
a working snippet:
syscall equ int 80h
;initialize listening fd
;create socket descriptor
mov [p0],PF_INET
mov [p1],SOCK_STREAM
mov [p2],0
mov eax,__NR_socketcall
mov ebx,SYS_SOCKET
mov ecx,sparms
syscall
mov [fd],eax ;socket file descriptor
or eax,eax ;test return code
jns ibind ;ok
err 302
;bind to port
ibind: mov ecx,[fd] ;socket file descriptor
mov [p0],ecx ;socket file descriptor
mov [p1],sin ;socket address structure
mov [p2],sinl ;length of structure
mov eax,__NR_socketcall
mov ebx,SYS_BIND
mov ecx,sparms
syscall
or eax,eax ;test return code
jns ilistn ;ok
err 303
;listen for connections
ilistn: mov ecx,[fd] ;socket file descriptor
mov [p0],ecx ;socket file descriptor
mov [p1],5 ;max queue length
mov eax,__NR_socketcall
mov ebx,SYS_LISTEN
mov ecx,sparms
syscall
or eax,eax ;test return code
jns tstwrm ;ok
err 304
--
Chuck
http://www.pacificsites.com/~ccrayne/charles.html
.
- Follow-Ups:
- Re: Port binding under linux in ASM
- From: tin . cans . and . string
- Re: Port binding under linux in ASM
- References:
- Port binding under linux in ASM
- From: tin . cans . and . string
- Port binding under linux in ASM
- Prev by Date: Re: All is right !
- Next by Date: Re: Port binding under linux in ASM
- Previous by thread: Port binding under linux in ASM
- Next by thread: Re: Port binding under linux in ASM
- Index(es):