SDK IP Functions
-
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 << + 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 testclientand 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/n5dcozalso 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 << + 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