Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    SDK IP Functions

    SDK Help
    0
    41
    34.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 28/12/2009 at 15:27, xxxxxxxx wrote:

      ok, I tried to send a HTTP command thru the established IP connection on standard port 80 but whenever I call GeIpWaitForIncoming, it never returns (passed listener is correctly established before). C4D idles and I can´t do anything anymore.
      Do I need this at all? I am not fully sure I understand the listener intention but I thought it was necessary for getting the packages back. Is that so?

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 29/12/2009 at 07:29, xxxxxxxx wrote:

        Sorry for not answering sooner. I'll try to get an example from the developers. Unfortunatly I have no knowledge about the workings of network connections myself so I can't answer directly.

        PS. I'll address this asap in the new year. There is no chance for me to solve this over the holidays.

        cheers,
        Matthias

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 29/12/2009 at 08:26, xxxxxxxx wrote:

          thanks Matthias. Here is example code I wrote which apparently doesn´t work but shows how I thought it would be working. Maybe it helps resolving this faster (or helps others to resolve with us).

          LONG ferr = 0;  
            //Öffne IP Verbindung mit Standard Port 80 für HTTP anfragen  
            connection = GeIpOpenOutgoing("www.dpit2.de:80",this->Get(),10,100,FALSE,&ferr); if(!connection) return;  
            if(ferr!=0) GeIpCloseConnection(connection);  
            
            //Sende HTTP Anfrage für index.html  
            const CHAR httpbuf[44] = "GET http://www.dpit2.de/index.html HTTP/1.0";  
            GeIpSendBytes(connection,httpbuf,sizeof(CHAR)*44);  
            
            //Listener um Serverantwort zu erhalten (?? Hmm, macht irgendwie keinen Sinn...)  
            listener = GeIpOpenListener(0,80,this->Get(),1,FALSE,&ferr); if(!listener) return;  
            if(ferr!=0) GeIpCloseConnection(listener);  
            
            //Antwortverbindung (scheint für immer zu idlen...)  
            IpConnection* incoming = GeIpWaitForIncoming(listener,this->Get(),&ferr);  
            GePrint("zurück aus dem Vakuum");  
            //Größe des Antwortbuffers  
            LONG bytes = GeIpBytesInInputBuffer(incoming);  
            
            //Falls da was ist..  
            if(bytes>0)  
            {  
                //Einlesen  
                void* buffer = GeAlloc(bytes);  
                GeIpReadBytes(incoming,buffer,bytes);  
                //dealloziieren des Buffers  
                GeFree(buffer);  
            }  
            //Antwortverbindung kappen  
            GeIpCloseConnection(incoming);  
          
          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 10/01/2010 at 10:16, xxxxxxxx wrote:

            *pushing daisies*

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 21/01/2010 at 09:00, xxxxxxxx wrote:

              Just wanted to check back when you approximately will be able to provide an example. Any chance of a foreseeable point in time?

              Thanks

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 21/01/2010 at 09:39, xxxxxxxx wrote:

                Sorry I can not give an estimate.

                cheers,
                Matthias

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 21/01/2010 at 11:31, xxxxxxxx wrote:

                  ok thanks. Then I´ll be waiting...and I will be waiting. 😉

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 22/01/2010 at 00:56, xxxxxxxx wrote:

                    With GeIpOpenOutgoing, you try to connect to someone listening.
                    With GeIpOpenListener you start listening yourself on some port, and when someone trys to connect to you, you get a connection.

                    Sending data worked fine for me, receiving should too.

                    I'll include a testserver and a testclient I did a long time ago, the server should display the message sent through:

                    IpConnection *con;
                        con = GeIpOpenOutgoing("127.0.0.1:6000", bt, 10, 100, FALSE, &ferr);
                        CHAR buf[7] = "blabla";
                        GeIpSendBytes( con, buf, 7 );

                    on the same connection you can ofcoure also try to receive (wont work with my testserver though, since it doesnt send anything 🙂 )

                    btw, it should always be a good idea to escape your sending/receiving buffer with '\0' or '\r\n'

                    testserver, written in c++:
                    it listens on port 6000 and accepts any connection, when it receives something it displays it.

                    #include "stdafx.h"
                    #include "iostream"
                    #include "stdio.h"
                    #include "stdlib.h"
                    #include "string.h"
                    #include "windows.h"
                    #include "winsock2.h"

                    #define BUF_SIZ 4096

                    int rcv_Client(SOCKET s) {
                      char buf[BUF_SIZ];            // Buffer für empfangene Daten
                      int rcvCnt=0;
                      // Daten empfangen(blockiert)

                    while(true){
                          rcvCnt=recv(s, buf, sizeof(buf)-1, 0);
                          if (rcvCnt<=0) {
                              printf("geschlossen");
                              break;
                          }       
                          buf[rcvCnt]='\0';
                          printf("empfangen: %s\n", buf);
                      }

                    // Verbindung schließen
                      closesocket(s);

                    return 0;
                    }

                    int main() {
                      long  result;          // Enthält die Rückgabewerte der Funktionen
                      WSADATA wsa;           // Initialisierungs-Daten

                    // Mit WSAStartup werden die Sockets initialisiert
                      result = WSAStartup(MAKEWORD(2, 0), &wsa);
                      if(result != 0){
                          printf("Fehler bei WSAStartup() : Code %d\n", result);
                          return 0;
                      }
                      else {
                          printf("WSAStartup() erfolgreich!\n");
                      }

                    SOCKADDR_IN addrBind;  // Daten für das Binden an einen Port
                      // Initialisieren der Struktur SOCKADDR_IN
                      memset(&addrBind, 0, sizeof(SOCKADDR_IN));
                      addrBind.sin_port            = htons(6000);
                      addrBind.sin_family            = AF_INET;
                      addrBind.sin_addr.s_addr    = ADDR_ANY;

                    // Initialisierung des socketAccept
                      SOCKET socketAccept=socket(AF_INET, SOCK_STREAM, 0);   // Socket, der Verbindungen annimt
                     
                      result=bind(socketAccept, (SOCKADDR* ) &addrBind, sizeof(SOCKADDR_IN));
                      if(result == SOCKET_ERROR) {
                          printf("Fehler in bind() : Code %d\n", WSAGetLastError());
                          return 0;
                      }
                      else {
                          printf("bind() erfolgreich!\n");
                      }
                     
                      // socketAccept geht in den "listen-mode"
                      result = listen(socketAccept, 10);
                      if(result == SOCKET_ERROR) {
                          printf("Fehler in listen() : Code %d\n", WSAGetLastError());
                          return 0;
                      }
                      else {
                         printf("listen() erfolgreich!\n");
                      }

                    SOCKET socketConnect;  // Socket, der eine Verbindung enthält
                      sockaddr_in client;
                      int cli_size=sizeof(client);

                    while(true)
                      {
                          // accept() blockiert solang, bis eine Verbindung angenommen wurde
                          socketConnect = accept(socketAccept, (sockaddr* ) &client, &cli_size);
                         
                          if(socketConnect == SOCKET_ERROR) {
                              printf("Fehler in accept() : Code %dProgramm wird fortgesetzt\n",
                                     WSAGetLastError());
                              continue;
                          }
                          else {
                              SOCKADDR_IN addrTemp;
                              memset(&addrTemp, 0, sizeof(SOCKADDR_IN));
                              int len = sizeof(addrTemp);

                    if (getpeername(socketConnect, (sockaddr* ) &addrTemp, &len) < 0)
                                  printf("Fehler gepeername()");
                              else {
                                  printf("%s:%d verbunden\n", inet_ntoa(addrTemp.sin_addr), ntohs(addrTemp.sin_port));
                              }
                              rcv_Client(socketConnect);
                          }
                      }
                    }

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 22/01/2010 at 01:00, xxxxxxxx wrote:

                      listening for a connection and accepting it should work like this:

                      first you open a listener, when a client connects, you open a connection to accept (my guess is that this is what GeIpWaitForIncomming is for)
                      then you try to receive on the accept-connection (the listener keeps listening, or is closed)

                      something like this:

                      if ( !conListener )
                        {
                            conListener = GeIpOpenListener( ( (127 << 24) + (0 << 16) + (0 << 😎 + 1 ), 6000, bt, 10, TRUE, &ferr );
                            if ( conListener )
                            {
                                CHAR buf[200];
                                GeIpGetHostAddr( conListener, buf, 200 );
                                String str = String( buf );
                                GePrint( str );
                            }
                        }
                        if ( !conAccept )
                            conAccept = GeIpWaitForIncoming( conListener, bt, &ferr );
                       
                        LONG bytes = GeIpBytesInInputBuffer( conAccept );
                        if ( bytes > 0 )
                        {
                            CHAR buf[200];
                            GeIpReadBytes( conAccept, buf, bytes );
                       
                            String str = String( buf );
                            GePrint( str );
                        }

                      the problem is: I never received a thing on "conAccept" 🙂 (and also didnt on conListener), but the connection could be established, well not really, since doesnt seem to accept it (could be a bug)
                      -> just see what happens in TCPView (next post) when starting the testclient

                      and here for the simple client:

                      start this after opening the listening connection, since it tries to connect to port 6000 right on start
                      you can then send any kind of data through typing it in and pressing enter.

                      for further understanding on whats going on, try starting both the testserver and client, they will connect with each other.

                      #include "stdafx.h"
                      #include "stdio.h"
                      #include "stdlib.h"
                      #include <string>
                      #include "windows.h"
                      #include "winsock2.h"
                      #include "iostream"

                      int snd_Server(SOCKET s) {
                        int sndCnt=0;
                        char temp[200];
                        std::string msg;
                        while (true) {
                            std::cin.getline(temp, 100, '\n');
                            msg=temp;
                            msg+="\r\n";
                            sndCnt=send(s, msg.c_str(), msg.length(), 0);
                            if(sndCnt<0){
                                perror("Fehler Send");
                                return 1;
                            }
                        }
                        return 0;
                      }

                      int main(int argc, char **argv)
                      {
                        WSADATA wsa;
                        int res=WSAStartup(MAKEWORD(2,0), &wsa);
                        if(res!=0){
                            perror("Fehler WSAStartup");
                            return 1;
                        }

                      SOCKADDR_IN addr;
                        memset(&addr, 0, sizeof(SOCKADDR_IN));
                        addr.sin_port            = htons(6000);
                        addr.sin_family            = AF_INET;
                        addr.sin_addr.s_addr    = inet_addr("127.0.0.1");
                       
                        SOCKET socketConnect=socket(AF_INET, SOCK_STREAM, 0);

                      res=connect(socketConnect, (SOCKADDR* ) &addr, sizeof(addr));

                      if(res<0) {
                            perror("Fehler Connect");
                            return 2;
                        }

                      if (snd_Server(socketConnect)>0) return 3;
                        return 0;
                      }

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 22/01/2010 at 01:04, xxxxxxxx wrote:

                        you can d/l the binaries here:
                        http://ul.to/n5dcoz

                        also a very handy tool to see what programs are having listening or established connections is TCPView rom Sysinternals:
                        http://technet.microsoft.com/de-de/sysinternals/bb897437.aspx

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 19/11/2010 at 03:00, xxxxxxxx wrote:

                          I did some tests, and it seems to work quite straight forward.
                          You just need a thread for your client and your server, then it should work fine:

                          void SenderThread::Main(void)
                          {
                               while(!TestBreak())
                               {
                                    LONG ferr=0;
                                    UCHAR buf[] = "mymessage!\0";
                               
                                    IpConnection* sender=GeIpOpenOutgoing("127.0.0.1:9093", Get(), 100000, 100000, FALSE, &ferr;);
                                    GeIpSendBytes(sender, buf, 11);
                                    GeIpCloseConnection(sender);
                               }
                          }

                          void ReceiverThread::Main()
                          {
                               while(!TestBreak())
                               {
                                    ULONG ip = (127 << 24) + (0 << 16) + (0 << 😎 + 1;
                                    LONG ferr=0;
                                    IpConnection* listener=GeIpOpenListener(ip, 9093, Get(), 100000, FALSE, &ferr;);
                                    IpConnection* incoming = GeIpWaitForIncoming(listener, Get(), &ferr;);
                                    while(GeIpBytesInInputBuffer(incoming) ==0)
                                         GeSleep(10);
                                    LONG bufsize = GeIpBytesInInputBuffer(incoming);
                                    CHAR buf[11];
                                    GeIpReadBytes(incoming, buf, bufsize);
                                    GeIpCloseConnection(incoming);
                                    GeIpCloseConnection(listener);
                                    GePrint(String(buf));
                               }
                          }

                          1 Reply Last reply Reply Quote 0
                          • H
                            Helper
                            last edited by

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 19/11/2010 at 03:49, xxxxxxxx wrote:

                            affa,

                            I´m using an external library now but as you can see in my post above I did exactly as you did back then (also in a thread of course) and it didn´t work (even though it is straight forward). Maybe they fixed the behavior in R12. Did you try with R12 or also with previous versions? What is the purpose of your loop btw? Would be strange it works for you while it didn´t work back then. Would be interesting to know what made my code not work even if I don´t need it anymore.

                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 19/11/2010 at 04:48, xxxxxxxx wrote:

                              I only tried it in R11.5 yet, and there it seems to work quite fine.
                              The loop is just a remainder of my real code. I stripped it down for this example

                              1 Reply Last reply Reply Quote 0
                              • H
                                Helper
                                last edited by

                                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                On 19/11/2010 at 05:36, xxxxxxxx wrote:

                                Hey. Can you get a http request through with it? Or did you only test custom buffer sending (like sending/getting your own stuff onto/from your server)?

                                thx

                                1 Reply Last reply Reply Quote 0
                                • H
                                  Helper
                                  last edited by

                                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                  On 21/11/2010 at 22:43, xxxxxxxx wrote:

                                  i only tested sending my own stuff between two Cinema instances

                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    Helper
                                    last edited by

                                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                    On 22/11/2010 at 01:47, xxxxxxxx wrote:

                                    Ah ok, I see. Thanks for the info anyway

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post