• [ace-users] ACE_SOCK_Stream not sending data

    From yanhangxiong@gmail.com@21:1/5 to All on Sat Nov 28 10:32:49 2015
    Hi, everyone,

    I'm using ACE to implement a simple application using acceptor-connector and reactor framework. I got some problems with the connection.

    In short, the client can normally send the data, but the server won't call svc_handler's handle_input() method. The only time this method is triggered is when closing the stream. However, the acceptor's handle_input() method can be properly triggered.

    Another observation is that when I manually increate the buffer size to send (10*BUFSIZ), server's handle_input() can be triggered, but the data is pretty random.

    Also, everything works perfectly when I run the client and server on a single machine (communicated by The problem above occurs when I run the client and server on separate machines.

    I'm programming on OS X El Captian and Ubuntu 15.04, using clang.
    The following is some code segments:


    ACE_SOCK_Stream stream;
    ACE_SOCK_Connector connector;
    if(connector.connect(stream, remote_addr) < 0){
    cerr << "Can not connect to Producer!" << endl;
    return returnType::ECONNECTION;

    for(int i=0; i<10; i++) {
    if (sendPlayList(director, stream, local_port) < 0) {
    cerr << "Can not connect to Producer" << endl;
    return returnType::ECONNECTION;
    stream.send() is called inside sendPlayList()


    class ProducerInputHandler : public ACE_Svc_Handler<ACE_SOCK_Stream, ACE_NULL_SYNCH> {
    inline void setPlayList(const std::shared_ptr<PlayList> playlist_,
    const std::shared_ptr<unique_set> unique_addr_) {
    playlist = playlist_;
    unique_addr = unique_addr_;
    int parseCommand(const std::string& str);
    virtual int handle_input(ACE_HANDLE=ACE_INVALID_HANDLE);
    virtual int handle_close(ACE_HANDLE, ACE_Reactor_Mask);

    std::shared_ptr<PlayList> playlist;
    std::shared_ptr<unique_set> unique_addr;

    class ProducerAcceptor: public ACE_Acceptor<ProducerInputHandler, ACE_SOCK_Acceptor>{
    ProducerAcceptor(const std::shared_ptr<PlayList> playlist_,
    const std::shared_ptr<unique_set> unique_addr_):
    playlist(playlist_) , unique_addr(unique_addr_){}
    virtual int make_svc_handler(ProducerInputHandler *&sh){
    printf("Connection received\n");
    ProducerInputHandler *h;
    ACE_NEW_RETURN(h, ProducerInputHandler(), -1);
    sh = h;
    sh->setPlayList(playlist, unique_addr);
    return 0;
    const std::shared_ptr<PlayList> playlist;
    const std::shared_ptr<unique_set> unique_addr;

    int ProducerInputHandler::handle_input(ACE_HANDLE h){
    char data[BUFSIZ] = {};
    ACE_SOCK_Stream& stream = peer();
    string str;
    ssize_t res = stream.recv(data,sizeof(data));
    cout << "size: " << res << endl;
    if(res <= 0)
    return -1;
    return parseCommand(str);

    So am I doing something wrong?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)