Serial communication with jSerialComm not sending anything - scala

I built a simple Scala application and a simple Arduino script to test serial communication on the jSerialComm library. The program only finds one active port (the one the Arduino connected to), the baud rates are the same on the port and the Arduino and the code throws no exceptions while writing. The Arduino, however, receives nothing (the RX led is off).
The Scala code:
import com.fazecast.jSerialComm._
object Test extends App {
val ports = SerialPort.getCommPorts
ports.foreach(println(_))
val port: SerialPort = ports(0)
var bytes = Array[Byte]()
val toWrite: Long = 3
var a = 0
var b = 0
var c = 0
println(port.getBaudRate)
while (true) {
if (a < 3) a += 1 else a = 0
bytes = Array[Byte](a.toByte, a.toByte, a.toByte)
port.writeBytes(bytes, toWrite)
println("Sent " + bytes(0) + " to " + port.toString)
Thread.sleep(1000)
}
}
The Arduino code:
const int R = 12;
const int G = 13;
const int B = 11;
void setup() {
pinMode(R, OUTPUT);
pinMode(G, OUTPUT);
pinMode(B, OUTPUT);
Serial.begin(9600);
while(!Serial);
}
void loop() {
byte buff[3] = {0, 0, 0};
int numR = 0;
bool cont1 = false;
bool cont2 = false;
bool cont3 = false;
if(Serial.available()){
Serial.print("Found stuff");
Serial.readBytes(buff,3);
}
for(int i = 0; i < 3; i++){
if(buff[i] == 1){
cont1 = true;
}
if(buff[i] == 2){
cont2 = true;
}
if(buff[i] == 3){
cont3 = true;
}
}
if(cont1) digitalWrite(R, HIGH); else digitalWrite(R, LOW);
if(cont2) digitalWrite(G, HIGH); else digitalWrite(G, LOW);
if(cont3) digitalWrite(B, HIGH); else digitalWrite(B, LOW);
if(cont1 || cont2 || cont3) delay(1000);
}

I had forgotten to open the port with
port.openPort()
Now it works just fine

Related

How to resolve the Mac address for an IP address under kernel module developing?

I want to build a tcp package in a kernel module and send it to another host by IP address using function dev_queue_xmit(skb). But I don't want to fill the Mac address manually by hand. The following is code for package producing.
Some kernel functions call eth_rebuild_header(skb) to rebuild Mac header. However, in my case, it hangs my computer after being called. Google results answers that arp_find will crash the OS if the arp cache contains not entry for that IP address. But I'm sure the it exists in the arp cache as printed by shell command "arp -v".
static int build_and_xmit_tcp(char * eth, u_char * smac, u_char * dmac,
u_long sip, u_long dip,
u_short sport, u_short dport,
u_char * pkt, int pkt_len,
int syn, int ack, int fin,
__be32 seq, __be32 seq_ack)
{
struct sk_buff * skb = NULL;
struct net_device * dev = NULL;
struct ethhdr * ethdr = NULL;
struct iphdr * iph = NULL;
struct tcphdr * tcph = NULL;
u_char * pdata = NULL;
if(NULL == smac || NULL == dmac)
goto out;
if(NULL == (dev= dev_get_by_name(&init_net, eth)))
goto out;
skb = alloc_skb(pkt_len + sizeof(struct iphdr) + sizeof(struct tcphdr) + LL_RESERVED_SPACE(dev), GFP_ATOMIC);
if(NULL == skb)
goto out;
skb_reserve(skb, LL_RESERVED_SPACE(dev));
skb->dev = dev;
skb->pkt_type = PACKET_OTHERHOST;
skb->protocol = __constant_htons(ETH_P_IP);
skb->ip_summed = CHECKSUM_NONE;
skb->priority = 0;
skb_set_network_header(skb, 0);
skb_put(skb, sizeof(struct iphdr));
skb_set_transport_header(skb, sizeof(struct iphdr));
skb_put(skb, sizeof(struct tcphdr));
pdata = skb_put(skb, pkt_len);
{
if(NULL != pkt)
memcpy(pdata, pkt, pkt_len);
}
tcph = tcp_hdr(skb);
memset(tcph, 0, sizeof(struct tcphdr));
tcph->source = sport;
tcph->dest = dport;
tcph->doff=5;
tcph->seq = htonl(seq);
tcph-> ack_seq= htonl( seq_ack);
tcph->psh = pkt_len>0? 1:0;
tcph ->fin = fin;
tcph->ack = ack;
tcph->syn=syn;
tcph->window=__constant_htons (65535);
skb->csum = 0;
tcph->check = 0;
iph = ip_hdr(skb);
iph->version = 4;
iph->ihl = sizeof(struct iphdr)>>2;
iph->frag_off = 0;
iph->protocol = IPPROTO_TCP;
iph->tos = 0;
iph->daddr = dip;
iph->saddr = sip;
iph->ttl = 0x40;
iph->tot_len = __constant_htons(skb->len);
iph->check = 0;
iph->check = ip_fast_csum((unsigned char *)iph,iph->ihl);
skb->csum = skb_checksum(skb, iph->ihl*4, skb->len - iph->ihl * 4, 0);
tcph->check = csum_tcpudp_magic(sip, dip, skb->len - iph->ihl * 4, IPPROTO_TCP, skb->csum);
skb_push(skb, 14);
skb_set_mac_header(skb, 0);
ethdr = (struct ethhdr *)eth_hdr(skb);
// memcpy(ethdr->h_dest, dmac, ETH_ALEN);
// memcpy(ethdr->h_source, smac, ETH_ALEN);
ethdr->h_proto = __constant_htons(ETH_P_IP);
// arp_send(ARPOP_REQUEST, ETH_P_ARP, target, dev, saddr,
// dst_ha, dev->dev_addr, NULL);
eth_rebuild_header(skb); // kernel hang....
if(0 > dev_queue_xmit(skb)) {
dev_put (dev);
kfree_skb (skb);
}
return(NF_ACCEPT);
out:
dev_put (dev);
kfree_skb (skb);
return(NF_ACCEPT);
}
static int __init myhook_init(void)
{
printk("=========insert module......\n");
build_and_xmit_tcp(ETH_O, GWMAC_O, DMAC, in_aton(GWIP_O), in_aton(DIP), htons(8888), htons(DPORT),
"", 0,
1, 0, 0, 0, 0);
}
static void __exit myhook_fini(void)
{
printk("=========rmmod ......\n");
}
module_init(myhook_init);
module_exit(myhook_fini);
Google gives me some other solution. They say arp_ioctl can resolve the Mac address. However, the fact is that, arp_ioctl is compiled statically into vmlinuz, which is not exported as a symbol to other modules.
int arp_get(char *ifname, char *ipStr)
{
struct arpreq req;
struct sockaddr_in *sin;
int ret = 0;
int sock_fd = 0;
struct net_device * dev = NULL;
printk("arp ---- \n");
if(NULL == (dev= dev_get_by_name(&init_net, ifname))){
dev_put (dev);
printk("error dev get \n");
return -1;
}
struct net *net_arp = dev_net(dev);
memset(&req, 0, sizeof(struct arpreq));
sin = (struct sockaddr_in *)&req.arp_pa;
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = in_aton(ipStr);
strncpy(req.arp_dev, ifname, 15);
ret = arp_ioctl(net_arp, SIOCGARP, &req); // can't be called
unsigned char *hw = (unsigned char *)req.arp_ha.sa_data;
printk("%#x-%#x-%#x-%#x-%#x-%#x\n", hw[0], hw[1], hw[2], hw[3], hw[4], hw[5]);
return 0;
}
Maybe I need make a socket structure, and try some upper functions based on a socket. But how to do it...
kernel version : 2.6.32
os version: ubuntu 9.10
gcc version : 4.41
int ip_xmit(struct sk_buff *skb)
{
struct iphdr *iph = ip_hdr(skb);
struct tcphdr *tcph = tcp_hdr(skb);
printk("dst is %d\n", skb->_skb_dst);
int err;
// err = ip_route_input(skb, iph->daddr, iph->saddr, 0, skb->dev);
struct rtalbe *rt;
{
struct flowi fl = { .oif = 0,
.nl_u = { .ip4_u =
{ .daddr = iph->daddr,
.saddr = iph->saddr,
.tos = 0 } },
.proto = IPPROTO_TCP,
.flags = 0,
.uli_u = { .ports =
{ .sport = tcph->source,
.dport = tcph->dest } } };
if (err = ip_route_output_key(&init_net, &rt, &fl))
return err;
printk("err is %d\n", err);
}
skb_dst_set(skb, rt);
if(0 > ip_local_out(skb)) {
printk("dev error\n");
kfree_skb (skb);
return -1;
}
return 0;
}
function ip_route_output_key can obtain the route destination, and ip_local_out deliver the skb out.

I receiving unknow data in my esp 8266

I need upload my own program on esp8266 and i tried to upload a program for test and i see esp reset maybe evry 200 ms and i am receivig a lot of data on usart but isn't my data in program .data is something like exception and some bytes about stack and some data about load and reset again
this is my test code
#include <ESP8266WiFi.h>
#define MAX_SRV_CLIENTS 1
#define TCP_PORT (23)
WiFiServer tcpServer(TCP_PORT);
WiFiClient tcpServerClients[MAX_SRV_CLIENTS];
IPAddress apIP(192, 168, 1, 1);
const char SSID[] = "TCPUARTBridge";
const char PASSWORD[] = "12345678";
#define SerialDebug Serial1
#define SerialGPS Serial
#ifndef min
#define min(x,y) ((x)<(y)?(x):(y))
#endif
void setup() {
SerialDebug.begin(115200);
SerialDebug.println("TCP <-> UART bridge");
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP(SSID, PASSWORD);
SerialGPS.begin(9600);
tcpServer.begin();
tcpServer.setNoDelay(true);
SerialDebug.print("Ready! Use 'telnet or nc ");
SerialDebug.print(WiFi.localIP());
SerialDebug.print(' ');
SerialDebug.print(TCP_PORT);
SerialDebug.println("' to connect");
}
void loop() {
uint8_t i;
char buf[1024];
int bytesAvail, bytesIn;
if (tcpServer.hasClient()) {
for (i = 0; i < MAX_SRV_CLIENTS; i++) {
if (!tcpServerClients[i] || !tcpServerClients[i].connected()) {
if (tcpServerClients[i])
tcpServerClients[i].stop();
tcpServerClients[i] = tcpServer.available();
SerialDebug.print("New client: "); SerialDebug.print(i);
continue;
}
}
WiFiClient tcpServerClient = tcpServer.available();
tcpServerClient.stop();
}
for (i = 0; i < MAX_SRV_CLIENTS; i++) {
if (tcpServerClients[i] && tcpServerClients[i].connected()) {
while ((bytesAvail = tcpServerClients[i].available()) > 0) {
bytesIn = tcpServerClients[i].readBytes(buf, min(sizeof(buf), bytesAvail));
if (bytesIn > 0) {
SerialGPS.write(buf, bytesIn);
delay(0);
}
}
}
}
while ((bytesAvail = SerialGPS.available()) > 0) {
bytesIn = SerialGPS.readBytes(buf, min(sizeof(buf), bytesAvail));
if (bytesIn > 0) {
for (i = 0; i < MAX_SRV_CLIENTS; i++) {
if (tcpServerClients[i] && tcpServerClients[i].connected()) {
tcpServerClients[i].write((uint8_t*)buf, bytesIn);
delay(0);
}
}
}
}
}
Thank you for reading this

Arduino Ethernet Shield connection to socket server

I'm using an ethernet shield for Arduino to connect it to a socket server (different computer) so that I can receive messages from it to activate some routine. Here is my code:
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x5A, 0x21 };
byte ip[] = { 192,168,1,11 }; //ip shield
byte server[] = { 192,168,1,7 }; // ip server
EthernetClient client;
String readString;
int ledPins[] = {19, 17, 2,3, 5, 6, 7, 8, 9}; // leds pins
int pinCount = 8;// number of leds
int const PINEYES = 9; //pin for different led
int const TIMERLEDS = 1000;
int const TIMERTOOFF= 3000;
//--------------------------------------------------------------------------
void setup() {
turnOffLeds();
Ethernet.begin(mac, ip);
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
if (client.connect(server, 1400)) {
Serial.println("connected");
client.println();
} else {
Serial.println("connection failed");
}
pinMode(PINEYES, OUTPUT);
int thisPin;
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
}
}
//--------------------------------------------------------------------------
void loop() {
if (client.available()) {
char c = client.read();
if (readString.length() < 30) {
if(c!='|')
readString.concat(c);
else {
client.flush();
//if (readString == "START_SENSATIONS") {
if (readString == "on") {
Serial.println("recebi");
client.stop();
turnOnMaya();
}
resetString();
}
}
Serial.println(readString);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}
//--------------------------------------------------------------------------
void turnOnMaya(){
turnOnLeds();
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
delay(TIMERLEDS);
digitalWrite(ledPins[thisPin], LOW);
}
turnOnEyes();
delay(TIMERTOOFF);
turnOffLeds();
digitalWrite(PINEYES, LOW);
client.connect(server, 1400);
}
//--------------------------------------------------------------------------
void turnOnLeds(){
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
digitalWrite(ledPins[thisPin], HIGH);
}
}
//--------------------------------------------------------------------------
void turnOffLeds(){
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
digitalWrite(ledPins[thisPin], LOW);
}
}
//--------------------------------------------------------------------------
void turnOnEyes(){
digitalWrite(PINEYES, 255);
}
//--------------------------------------------------------------------------
void resetString() {
readString = "";
}
The problem is, when my server stops or is not available for some moments, I need my Arduino to keep on trying to connect to it until it is available again. But I can't make this work.
I tried this:
while(!client.available()){
Serial.println("connection failed, trying again...");
client.connect(server, 1400);
delay(1000);
}
But it doesn't work. It just prints "connection failed, trying again..." forever. How can I do this?
Thanks!
I'm assuming that the server in your PC is a normal java or c (or any other standard tcp server)
But your arduino client doesn't specify that it is TCP. So either change your server or the client(like in here - this uses wifi connection).
If your server is in java, it could be like this:
int port=9999;
try{
System.out.println("Starting server...");
ServerSocket ss=new ServerSocket(port);
Socket clientSocket=ss.accept();
System.out.println("Connection has been established...");
PrintWriter out=new PrintWriter(clientSocket.getOutputStream(),true);
BufferedReader br=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
String inputLine;
System.out.println("Listening.....");
while((inputLine=br.readLine())!=null)
System.out.println(inputLine);
}catch(Exception e){System.out.println(e.getMessage());}

JPEG streaming with live555

I want to stream JPEG images or motion-JPEG file through live 555. But the problem is that in live 555 implementation for Jpegs is not available. Anyone can help ??
You can find a implementation that was posted to the devel mailing list http://lists.live555.com/pipermail/live-devel/2012-February/014672.html.
The code and a sample is available but this modification was rejected by live555 maintainer.
First we need to implement an MJPEGVideoSource than can feed a JPEGVideoRTPSink.
#include "JPEGVideoSource.hh"
class MJPEGVideoSource : public JPEGVideoSource
{
public:
static MJPEGVideoSource* createNew (UsageEnvironment& env, FramedSource* source)
{
return new MJPEGVideoSource(env,source);
}
virtual void doGetNextFrame()
{
if (m_inputSource)
m_inputSource->getNextFrame(fTo, fMaxSize, afterGettingFrameSub, this, FramedSource::handleClosure, this);
}
virtual void doStopGettingFrames()
{
FramedSource::doStopGettingFrames();
if (m_inputSource)
m_inputSource->stopGettingFrames();
}
static void afterGettingFrameSub(void* clientData, unsigned frameSize,unsigned numTruncatedBytes,struct timeval presentationTime,unsigned durationInMicroseconds)
{
MJPEGVideoSource* source = (MJPEGVideoSource*)clientData;
source->afterGettingFrame(frameSize, numTruncatedBytes, presentationTime, durationInMicroseconds);
}
void afterGettingFrame(unsigned frameSize,unsigned numTruncatedBytes,struct timeval presentationTime,unsigned durationInMicroseconds)
{
int headerSize = 0;
bool headerOk = false;
fFrameSize = 0;
for (unsigned int i = 0; i < frameSize ; ++i)
{
// SOF
if ( (i+8) < frameSize && fTo[i] == 0xFF && fTo[i+1] == 0xC0 )
{
m_height = (fTo[i+5]<<5)|(fTo[i+6]>>3);
m_width = (fTo[i+7]<<5)|(fTo[i+8]>>3);
}
// DQT
if ( (i+5+64) < frameSize && fTo[i] == 0xFF && fTo[i+1] == 0xDB)
{
if (fTo[i+4] ==0)
{
memcpy(m_qTable, fTo + i + 5, 64);
m_qTable0Init = true;
}
else if (fTo[i+4] ==1)
{
memcpy(m_qTable + 64, fTo + i + 5, 64);
m_qTable1Init = true;
}
}
// End of header
if ( (i+1) < frameSize && fTo[i] == 0x3F && fTo[i+1] == 0x00 )
{
headerOk = true;
headerSize = i+2;
break;
}
}
if (headerOk)
{
fFrameSize = frameSize - headerSize;
memmove( fTo, fTo + headerSize, fFrameSize );
}
fNumTruncatedBytes = numTruncatedBytes;
fPresentationTime = presentationTime;
fDurationInMicroseconds = durationInMicroseconds;
afterGetting(this);
}
virtual u_int8_t type() { return 1; };
virtual u_int8_t qFactor() { return 128; };
virtual u_int8_t width() { return m_width; };
virtual u_int8_t height() { return m_height; };
u_int8_t const* quantizationTables( u_int8_t& precision, u_int16_t& length )
{
length = 0;
precision = 0;
if ( m_qTable0Init && m_qTable1Init )
{
precision = 8;
length = sizeof(m_qTable);
}
return m_qTable;
}
protected:
MJPEGVideoSource(UsageEnvironment& env, FramedSource* source) : JPEGVideoSource(env),
m_inputSource(source),
m_width(0),
m_height(0),
m_qTable0Init(false),
m_qTable1Init(false)
{
memset(&m_qTable,0,sizeof(m_qTable));
}
virtual ~MJPEGVideoSource()
{
Medium::close(m_inputSource);
}
protected:
FramedSource* m_inputSource;
u_int8_t m_width;
u_int8_t m_height;
u_int8_t m_qTable[128];
bool m_qTable0Init;
bool m_qTable1Init;
};
Next we can use it as a video source in order to build a simple RTSP server:
#include "liveMedia.hh"
#include "BasicUsageEnvironment.hh"
#include "GroupsockHelper.hh"
#include "MJPEGVideoSource.hh"
char const* inputFileName = "test.mjpeg";
int main(int argc, char** argv) {
// Begin by setting up our usage environment:
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
// Create 'groupsocks' for RTP and RTCP:
struct in_addr destinationAddress;
destinationAddress.s_addr = chooseRandomIPv4SSMAddress(*env);
const unsigned short rtpPortNum = 18888;
const unsigned short rtcpPortNum = rtpPortNum+1;
const unsigned char ttl = 255;
const Port rtpPort(rtpPortNum);
const Port rtcpPort(rtcpPortNum);
Groupsock rtpGroupsock(*env, destinationAddress, rtpPort, ttl);
rtpGroupsock.multicastSendOnly(); // we're a SSM source
Groupsock rtcpGroupsock(*env, destinationAddress, rtcpPort, ttl);
rtcpGroupsock.multicastSendOnly(); // we're a SSM source
// Create a 'JPEG Video RTP' sink from the RTP 'groupsock':
RTPSink* videoSink = JPEGVideoRTPSink::createNew(*env, &rtpGroupsock);
// Create (and start) a 'RTCP instance' for this RTP sink:
const unsigned estimatedSessionBandwidth = 5000; // in kbps; for RTCP b/w share
const unsigned maxCNAMElen = 100;
unsigned char CNAME[maxCNAMElen+1];
gethostname((char*)CNAME, maxCNAMElen);
CNAME[maxCNAMElen] = '\0'; // just in case
RTCPInstance* rtcp = RTCPInstance::createNew(*env, &rtcpGroupsock,
estimatedSessionBandwidth, CNAME,
videoSink, NULL /* we're a server */,
True /* we're a SSM source */);
// Note: This starts RTCP running automatically
RTSPServer* rtspServer = RTSPServer::createNew(*env, 8554);
if (rtspServer == NULL) {
*env << "Failed to create RTSP server: " << env->getResultMsg() << "\n";
exit(1);
}
ServerMediaSession* sms = ServerMediaSession::createNew(*env, "testStream", inputFileName,"Session streamed by \"testMJPEGVideoStreamer\"",
True /*SSM*/);
sms->addSubsession(PassiveServerMediaSubsession::createNew(*videoSink, rtcp));
rtspServer->addServerMediaSession(sms);
char* url = rtspServer->rtspURL(sms);
*env << "Play this stream using the URL \"" << url << "\"\n";
delete[] url;
// Start the streaming:
*env << "Beginning streaming...\n";
// Open the input file as a 'byte-stream file source':
ByteStreamFileSource* fileSource = ByteStreamFileSource::createNew(*env, inputFileName);
if (fileSource == NULL) {
*env << "Unable to open file \"" << inputFileName
<< "\" as a byte-stream file source\n";
exit(1);
}
// Create the MJPEG video source:
MJPEGVideoSource* videoSource = MJPEGVideoSource::createNew(*env, fileSource);
// Finally, start playing:
*env << "Beginning to read from file...\n";
videoSink->startPlaying(*videoSource, NULL, NULL);
env->taskScheduler().doEventLoop();
return 0;
}
Hope you have done it but if not-
see this Jpeg Streaming using live555
This is doing the same thing as you have asked to stream the images/Jpegs.
For MJpegs you'll have to do the same process.

Recv fails when using python sendall in iOS project

I have a python server that is trying to send a binary file to a client on iOS but 90% of the time the file is incomplete. The receive call on the client fails after receiving about 80% of the file.
This is basically how it's setup.
Server
class ForkingTCPRequestHandler(SocketServer.BaseRequestHandler):
def handle(self):
f = open(TEST_FILE_NAME, 'rb')
file_data = f.read()
self.request.sendall(file_data)
f.close()
class ForkingTCPServer(SocketServer.ForkingMixIn, SocketServer.TCPServer):
pass
if __name__ == '__main__':
try:
server = ForkingTCPServer(('0.0.0.0', 9000), ForkingTCPRequestHandler)
except socket.error as e:
sys.exit(1)
try:
server.serve_forever()
except KeyboardInterrupt:
server.shutdown()
sys.exit(0)
This code works outside of our iOS project (entire file is received)
int receiveFile() {
/* ... */
/* Receive file */
tempBuf = (char*) malloc(sizeof(char)*fileLen);
totalRecv = 0;
recvBytes = 0;
while (totalRecv < fileLen) {
recvBytes = recv(s, tempBuf+totalRecv, 1<<14, 0);
if (recvBytes < 0) {
free(tempBuf);
close(s);
return -1;
}
totalRecv += recvBytes;
}
close(s);
return 0;
}
int connectToServerWithHostname(char *hostname, char *port) {
/* ... */
memset(&targetAddr, 0, sizeof(targetAddr));
targetAddr.sin_family = AF_INET;
targetAddr.sin_port = htons(atoi(port));
bcopy(hostdetails->h_addr, (char *)&targetAddr.sin_addr, hostdetails->h_length);
sock = socket(AF_INET, SOCK_STREAM, 0);
if (socket < 0) {
return -1;
}
rc = connect(sock, (struct sockaddr *)&targetAddr, sizeof(targetAddr));
if (rc < 0) {
close(sock);
return -1;
}
return sock;
}
int main(int argc, char **argv) {
assert(!receiveFile());
return 0;
}
But this equivalent code inside our iOS project fails (partial receive). Even though I'm connecting and receiving the same way as the code above.
while (totalRecv < ntohl(symProcPacket.totalDataLen)) {
recvBytes = recv(s, tempBuf+totalRecv, DEFAULT_SENDRECVSIZE, DEFAULT_SENDRECV_FLAGS);
if (recvBytes < 0) {
debug("Error, could not receive file\n");
free(tempBuf);
errorType = kSymClientErrorReceiving;
goto errorImporting;
}
totalRecv += recvBytes;
printf("Received: %d/%d\n", totalRecv, ntohl(symProcPacket.totalDataLen));
}
Any ideas on why this is failing?
Are sockets different in an iOS project or something?