Some c interface related questions

I am trying to understand how to use c and ats together , the code given
here r1.datshttps://bitbucket.org/chotu/ats-explore/src/6b36893fe0b370656436120c5ae838bd64e26357/with-c/r1.dats?at=master
is my attempt to use sockets. Everything works fine(compile and run) but
can’t seem to handle function “bind” properly (specially 2nd argument i.e
how to cast sockaddr_in to sockaddr ).

Just a side note , my c is not that good :smiley:

Thanks.

Using ext#bind means to have two interfaces for ‘bind’: one in C and one in
ATS.
In this case, these two interfaces are incompatible. Using "mac#bind’ is
the right way to go.

Usually, you want to do something like

fun bind (…): … = “mac#mybind”

where ‘mybind’ is defined as a macro in C:

#define mybind(…) bind(…)

In this way, you can suppress warnings from gcc due to a call to ‘bind’.

The socket stuff is at a very low-level. For serious socket programming,
you can try:

http://www.ats-lang.org/LIBRARY/contrib/zeromq/zmq.htmlOn Saturday, January 25, 2014 4:41:32 AM UTC-5, chotu s wrote:

I am trying to understand how to use c and ats together , the code given
here r1.datshttps://bitbucket.org/chotu/ats-explore/src/6b36893fe0b370656436120c5ae838bd64e26357/with-c/r1.dats?at=master
is my attempt to use sockets. Everything works fine(compile and run) but
can’t seem to handle function “bind” properly (specially 2nd argument i.e
how to cast sockaddr_in to sockaddr ).

Just a side note , my c is not that good :smiley:

Thanks.