我想从套接字读取数据,然后使用fwrite将它们写入fuile,但我一直遇到异常。我的代码:
MyFile = fopen ("flash:/ngfm.bin","wb");
if (MyFile != NULL) {
while ((nBytes = read (dataSock, buf, sizeof (buf))) > 0) {
ByteCount++;
if (ByteCount %10)
printf(".");
if (ByteCount %100)
printf("\n");
fwrite( buf, sizeof(buf), nBytes, MyFile );
}
printf("%d Bytes written to flash:/ngfm.bin!\n", ByteCount);
fclose( MyFile );
}
close (dataSock);
这在
vxworks
上并且我的设备闪烁:存在并且可写!我在外壳上执行了以下操作:JPAX-DP> mf = fopen("flash:/test","w")
New symbol "mf" added to kernel symbol table.
mf = 0x26e75e90: value = 636346784 = 0x25ede1a0
JPAX-DP> fputs("TEST",mf)
value = 0 = 0x0
JPAX-DP> fclose(mf)
value = 0 = 0x0
JPAX-DP> ls("flash:/")
flash:/switch_demo_rem.vxs
flash:/switch_demo_lb_on.vxs
flash:/switch_demo_lb_off.vxs
flash:/switch_demo1b.vxs
flash:/switch_demo1a.vxs
flash:/switch_demo.vxs
flash:/sanity.soc
flash:/rc.soc
flash:/protection_init.vxs
flash:/pack_demo.vxs
flash:/init.vxs
flash:/config.bcm
flash:/BCM56440_B0_0.srec
flash:/BCM56440_A0_1.srec
flash:/BCM56440_A0_0.srec
flash:/jpax_msg.log
flash:/jpax_err.log
flash:/ngfm.bin
flash:/test
最佳答案
确保正确地声明了“ buf”并且足够大。
关于c - 从vxworks中的ftp套接字读取,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20574759/