accept and accept-nonblocking now set the port-id to a string

representing the incoming address like "nnn.nnn.nnn.nnn:pppp"
This commit is contained in:
Abdulaziz Ghuloum
2008-04-11 07:01:27 -04:00
parent 25344fa1d0
commit bdd81e2b05
4 changed files with 54 additions and 8 deletions
+32 -2
View File
@@ -59,6 +59,8 @@ ikrt_io_error(){
case EAGAIN : return fix(-22); /* hardcoded in ikarus.io.ss */
case EPIPE : return fix(-23);
case ECONNREFUSED : return fix(-24);
case ENOTSOCK : return fix(-25);
case ENOBUFS : return fix(-26);
}
return fix(-1);
}
@@ -251,12 +253,37 @@ ikrt_listen(ikptr port, ikpcb* pcb){
return fix(sock);
}
#if 0
not used
ikptr
ikrt_getsockname(ikptr s, ikpcb* pcb){
socklen_t size = sizeof(struct sockaddr);
ikptr bv = ik_safe_alloc(pcb, align(disp_bytevector_data+size))
+ bytevector_tag;
int r = getsockname(unfix(s),
(struct sockaddr*)(bv+off_bytevector_data),
&size);
if(r == 0){
ref(bv, off_bytevector_length) = fix(size);
return bv;
} else {
return ikrt_io_error();
}
}
#endif
ikptr
ikrt_accept(ikptr s, ikpcb* pcb){
int sock = accept(unfix(s), NULL, NULL);
ikrt_accept(ikptr s, ikptr bv, ikpcb* pcb){
socklen_t addrlen = unfix(ref(bv, off_bytevector_length));
int sock = accept(unfix(s),
(struct sockaddr*) (bv+off_bytevector_data),
&addrlen);
if(sock < 0){
return ikrt_io_error();
}
ref(bv, off_bytevector_length) = fix(addrlen);
return fix(sock);
}
@@ -287,3 +314,6 @@ ikrt_file_ctime(ikptr filename, ikptr res){
return fix(0);
}