Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use crossbridge to compile client.c to swc but failed because of a link error #66

Open
hgj100 opened this issue Mar 28, 2017 · 1 comment

Comments

@hgj100
Copy link

hgj100 commented Mar 28, 2017

client.c is a test code. This file contains socket API for example socket, connect, send, why only 'connect' result in link error?

source code client.c :

#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>

int test(int argc, char **argv)
{
int client_socket, port;
struct sockaddr_in serv_addr;
if(argc != 3)
{
printf("useage:socket_client ipaddress port");
return -1;
}

port = atoi(argv[2]);
if(-1 == (client_socket = socket(AF_INET,SOCK_STREAM,0)) )
{
    perror("error in create socket\n");
    exit(0);
}
bzero(&serv_addr,sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);
serv_addr.sin_addr.s_addr = inet_addr(argv[1]);

if(-1 == connect(client_socket,(struct sockaddr*)&serv_addr,sizeof(struct sockaddr)))
{
    perror("connect error\n");
    exit(0);
}

send(client_socket,"hello world",strlen("hello world"),0);

close(client_socket);

}

source code main.c :

#include "AS3/AS3.h"
int main()
{
AS3_GoAsync();
}

when compile,
$ make
-------- Sample 5 --------

Now compile a SWC and demo SWF
"/cygdrive/c/Crossbridge/sdk/usr/bin/g++" -Werror -Wno-write-strings -Wno-trigraphs -O4 main.cpp client.c -emit-swc=sample.test -o test.swc
/tmp/cclj1lfj.o: error: undefined reference to '_connect'
collect2: ld returned 1 exit status
Makefile:2: recipe for target `T05' failed
make: *** [T05] Error 1

If crossbridge sdk have some problem?

@mbolt35
Copy link

mbolt35 commented Mar 29, 2017

Since the AS3/Flash Player support for sockets doesn't map easily to posix sockets, it wasn't implemented in crossbridge. You can use AS3 sockets and pass data back and forth via inline_as3(). In other words, you can use sockets in your C++ app, but you'd need to write your own implementation.

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants