Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c - Sending file descriptor over UNIX domain socket, and select() -


i'm using unix domain socket transfer file descriptor process. works fine, when first try see if socket writeable using select(), sendmsg() call fails bad file descriptor error.

the sendmsg() function work fine in combination select() if don't add file descriptor info msghdr struct, conflict seems between select() , transferring file descriptors.

i couldn't find info on in man pages select(), recvmsg(), or other. since needs become server hands out file descriptors multiple processes, i'd still able use select().

is there can make work, or know of alternative solutions?

platform ubuntu 10.4.

this code initializes structures:

  struct cmsghdr_fd : public cmsghdr {   int fd; };  int sendfd(int sock, int fd) {   struct msghdr hdr;   struct iovec data;   struct cmsghdr_fd msgdata;    char dummy = '*';   data.iov_base = &dummy;   data.iov_len = sizeof(dummy);    hdr.msg_name = null;   hdr.msg_namelen = 0;   hdr.msg_iov = &data;   hdr.msg_iovlen = 1;   hdr.msg_flags = 0;    hdr.msg_control = &msgdata;   hdr.msg_controllen = sizeof(msgdata);    struct cmsghdr* cmsg = cmsg_firsthdr(&hdr);   cmsg->cmsg_len   = hdr.msg_controllen;   cmsg->cmsg_level = sol_socket;   cmsg->cmsg_type  = scm_rights;    *(int*)cmsg_data(cmsg) = fd;    int n = sendmsg(sock, &hdr, 0);    if(n == -1)     printf("sendmsg() failed: %s (socket fd = %d)\n", strerror(errno), sock);    return n; } 

again, works, long don't call select() first check whether socket ready writing.

i tried sendfd code @ this page, kindly provided nos, , though it's different, works when use in combination select(). code looks now:

      int sendfd(int sock, int fd)     {       struct msghdr hdr;       struct iovec data;        char cmsgbuf[cmsg_space(sizeof(int))];        char dummy = '*';       data.iov_base = &dummy;       data.iov_len = sizeof(dummy);        memset(&hdr, 0, sizeof(hdr));       hdr.msg_name = null;       hdr.msg_namelen = 0;       hdr.msg_iov = &data;       hdr.msg_iovlen = 1;       hdr.msg_flags = 0;        hdr.msg_control = cmsgbuf;       hdr.msg_controllen = cmsg_len(sizeof(int));        struct cmsghdr* cmsg = cmsg_firsthdr(&hdr);       cmsg->cmsg_len   = cmsg_len(sizeof(int));       cmsg->cmsg_level = sol_socket;       cmsg->cmsg_type  = scm_rights;        *(int*)cmsg_data(cmsg) = fd;        int n = sendmsg(sock, &hdr, 0);        if(n == -1)         printf("sendmsg() failed: %s (socket fd = %d)\n", strerror(errno), sock);        return n;         }  

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -