SDK IP Functions



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

    On 07/04/2008 at 02:15, xxxxxxxx wrote:

    The thread can be a thread passed by Cinema, for instance in a videopost plugin, or your own thread. You would call for instance GeIpWaitForIncoming within the Main() of your thread and pass this. ferr is just a LONG that is filled with the error code, you should check for ferr != 0. The IP address for GeIpOpenListener() is encoded like this (take 127.0.0.1 for example)

    > \> (127 << 24) + (0 << 16) + (0 << 8) + 1 \> or 7f000001 \>

    cheers,
    Matthias



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

    On 12/04/2008 at 12:57, xxxxxxxx wrote:

    Quote: Originally posted by kuroyume0161 on 18 December 2007
    >
    > * * *
    >
    >
    > I tried the SendMailAvailable() and SendMail() without any success (say, for a quick means of sending me logs). SendMailAvailable() always returned FALSE.
    >
    > * * *

    Hi,

    have you been able to send the e-mail finally? I still cannot. However SendMailAvailable() returns TRUE in my case. But I am unable to pass t_to parameter to the SendMail function. If I call it with NULL for t_to the default system mailer (thunderbird in my case) opens with right values for body and subject filled in. But as soon as t_to differs from NULL or empty string Cinema crashes. Does anyone successfully passed this parameter to the function?

    Here is the code:

    > String toadresa = "nekdo@nekde.com"; \> if (SendMailAvailable()) { \>      SendMail(String("subject"),&toadresa;,NULL,NULL,NULL,String("body"),SENDMAIL_SENDDIRECTLY); \> }

    Thanks in advance.



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

    On 05/02/2009 at 09:42, xxxxxxxx wrote:

    Hi,

    are there any news about the IP functions and their documentation?
    I managed to set up a thread in C4D waiting for an incoming connection on a given port. When the connection is initiated, I call GeIpBytesInInputBuffer and GeIpReadBytes, but both always give me 0 as return, although I'm sending data from the other end. And as far as I found out, there's no way of telling that the connection dropped, since there's no function for asking about the connection status and the GeIpBytesInInputBuffer and GeIpReadBytes still return 0 after I closed the connection from the other side.

    It am eager to use the IP functions, so it would be great if someone could help me out.

    cheers



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

    On 28/12/2009 at 10:29, xxxxxxxx wrote:

    Is there any news about this? I wonder why it´s so hard to get an answer for this IP issue. I mean some programmer must have made this available and it´s only a handful of functions so why is it so hard to provide a code sample? Especially when so many people ask for it.

    I´d really appreciate any info if this will be resolved or if the functions in the SDK are simply unusable in their current state.

    All my attempts are leading to nowhere. I could establish a connection and even reading bytes does return something (though I don´t know what) but I have absolutely no clue what this tells me or how to use this for a real purpose (e.g. getting files from a server).

    I am looking at external libraries now but if there was a chance to not rely on external libraries I definetly would.

    Thanks



  • 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?



  • 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



  • 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);  
    


  • 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*



  • 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



  • 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



  • 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. ;)



  • 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);
          }
      }
    }



  • 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 << 8) + 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;
    }



  • 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



  • 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 << 8) + 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));
         }
    }



  • 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.



  • 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



  • 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



  • 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



  • 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


Log in to reply