MSN服务器问题(Linux套接字编程) [英] Problem with MSN server (linux socket programming)

查看:206
本文介绍了MSN服务器问题(Linux套接字编程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用开源MSN Messenger(最旧的版本tmsnc),目前已不受支持.
问题出在套接字部分,它试图连接不再受支持的hotmail.messenger.com(作为主机地址),我对此进行了搜索,建议一些人使用

I''m trying to use an open source MSN messenger(tmsnc oldest version) and it is out of support right now.
The problem is in socket part it is trying to connect hotmail.messenger.com (as host address) which is not supported any more, I searched about that and some guys were suggested to use

报价:

messenger.hotmail.geo.msnmessenger.msn.com.akadns.net

messenger.hotmail.geo.msnmessenger.msn.com.akadns.net


相反,但是在将服务器发送给我其他部分(例如send())之后,它使我由于对等错误而重置了连接,有时甚至无法绑定它.

甚至有可能修复它吗?可以通过更换其他服务器或...

我尝试过的事情:

评论的部分是我的,我尝试使用getaddrinfo()模拟源部分并循环查找可能很好的结果,但是那样就连它都无法绑定.


instead but after it gives me the server in other parts such as send() it gives me connection reset by peer error or sometimes even cannot bind it.

Is that even possible to fix it? may by replacing other server or ...

What I have tried:

commented part is mine where i tried to simulate source part using getaddrinfo() and loop to find may a good result but in that way even it cannot bind.

int tcp_connect(char *server, int port)
 {
    /*
    struct addrinfo hints, *servinfo , *p;
    int sockfd;
    int rv;
    int yes = 1;
    
    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_STREAM;

    if ((rv = getaddrinfo("messenger.hotmail.geo.msnmessenger.msn.com.akadns.net", "4000", &hints, &servinfo)) != 0) {
            fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
            return 1;
    }

    // loop through all the results and bind to the first we can
    for(p = servinfo; p != NULL; p = p->ai_next) {
            if ((sockfd = socket(p->ai_family, p->ai_socktype,
                            p->ai_protocol)) == -1) {
                    perror("server: socket");
                    continue;
            }

            if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes,
                            sizeof(int)) == -1) {
                    perror("setsockopt");
                    exit(1);
            }

            if (bind(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
                    close(sockfd);
                    perror("server: bind");
                    continue;
            }
            
            if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
                close(sockfd);
                perror("client: connect");
                continue;
            }

            break;
    }

    freeaddrinfo(servinfo); // all done with this structure

    if (p == NULL)  {
            fprintf(stderr, "server: failed to bind\n");
            exit(1);
    }
    
    return sockfd;
    */    
        
        
        
    
    
        struct sockaddr_in localAddr, servAddr; // Used in connect and bind
        struct hostent *h; // Used for address resolving
        int rc; // Function return code
        int sd; // The socket descriptor

        //Resolve the address
        h = gethostbyname(server);
        if(h==NULL)
                return -1;

        servAddr.sin_family = h->h_addrtype;
        memcpy((char *) &servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
        servAddr.sin_port = htons(port);

        //Initialize the socket
        sd = socket(AF_INET, SOCK_STREAM, 0);
        if(sd<0)
                return -1;

        localAddr.sin_family = AF_INET;
        localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
        localAddr.sin_port = htons(0);

        //Bind a local port for recieving data 
        rc = bind(sd, (struct sockaddr *) &localAddr, sizeof(localAddr));
        if(rc<0)
                return -1;

        //Connect to the remote server
        rc = connect(sd, (struct sockaddr *) &servAddr, sizeof(servAddr));
        if(rc<0)
                return -1;

        return sd;
}

推荐答案

问题在于远程站点及其可用性.那不是编码问题.尝试 https://www.messenger.com/ [ ^ ].
The problem is with the remote site and its availability. That is not a coding issue. Try https://www.messenger.com/[^].


这篇关于MSN服务器问题(Linux套接字编程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆