小编The*_*ker的帖子

在.Net中查找下一个TCP端口

我想为WCF服务调用创建一个新的net.tcp:// localhost:x/Service端点,并使用动态分配的新的open tcp端口.

我知道当我打开与给定服务器的连接时,TcpClient将分配一个新的客户端端口.

有没有一种简单的方法可以在.Net中找到下一个打开的TCP端口?

我需要实际的数字,以便我可以构建上面的字符串,0不起作用,因为我需要将该字符串传递给另一个进程,以便我可以回调该新的通道.

.net c# wcf networking tcp

62
推荐指数
6
解决办法
3万
查看次数

在Linux上使用I2C读/写

我正在尝试读取/写入FM24CL64-GTR FRAM通过地址上的I2C总线连接的芯片0b 1010 011.

当我试图写3个字节(数据地址2个字节,+数据一个字节)时,我得到一个内核消息([12406.360000] i2c-adapter i2c-0: sendbytes: NAK bailout.),以及写返回!= 3.参见下面的代码:

#include <linux/i2c-dev.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>

int file;
char filename[20];
int addr = 0x53; // 0b1010011; /* The I2C address */
uint16_t dataAddr = 0x1234;
uint8_t val = 0x5c;
uint8_t buf[3];

sprintf(filename,"/dev/i2c-%d",0);
if ((file = open(filename,O_RDWR)) < 0)
    exit(1);

if (ioctl(file,I2C_SLAVE,addr) < 0)
    exit(2);

buf[0] = dataAddr >> 8;
buf[1] = dataAddr & 0xff;
buf[2] = val;

if (write(file, buf, 3) …
Run Code Online (Sandbox Code Playgroud)

c linux ioctl i2c

13
推荐指数
2
解决办法
5万
查看次数

有没有一种标准的方法来做findfirst,使用stl在linux上使用gcc查找下一个?

我似乎无法在Linux的gcc上找到_findfirst/findfirst,_findnext/findnext API,如果它包含在那里,实际上更愿意使用标准模板库(STL).

有谁知道在Linux for C++(gcc)下的目录中列出文件的API是什么?

c++ linux gcc stl file

9
推荐指数
2
解决办法
1万
查看次数

为gcc-arm工具链提升C++库

构建1.35.0以及在timesys arm-gcc工具链上的1.36.0,无论是静态(链接静态)还是动态(.so,默认选项)都没有问题.

但是,当我尝试链接一个简单的示例文件系统应用程序时:

#include <boost/filesystem.hpp>
#include <iostream>

namespace fs = boost::filesystem;

int main(int argc, char *argv[]) {
    const char* fileName = argv[1];
    std::cout << "file: " << fileName << " => " << fs::exists(fileName) << std::endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我收到以下链接器错误:


developer@eldp01:~/boost/test$ /opt/timesys/at91sam9263_ek/toolchain/bin/armv5l-timesys-linux-gnueabi-gcc 
  exists.cpp -o exists.exe -I ../boost_1_35_0/ -lboost_filesystem -lboost_system -lstdc++ -L .

/tmp/ccex3NGb.o: In function `boost::detail::atomic_decrement(int*)':
exists.cpp:(.text._ZN5boost6detail16atomic_decrementEPi[boost::detail::atomic_decrement(int*)]+0x1c): 
  undefined reference to `__sync_fetch_and_add_4'

/tmp/ccex3NGb.o: In function `boost::detail::atomic_increment(int*)':
exists.cpp:(.text._ZN5boost6detail16atomic_incrementEPi[boost::detail::atomic_increment(int*)]+0x1c): 
  undefined reference to `__sync_fetch_and_add_4'

collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

有谁知道如何让我的Boost为gcc-arm工具链构建?

c++ gcc boost arm

5
推荐指数
1
解决办法
7027
查看次数

标签 统计

c++ ×2

gcc ×2

linux ×2

.net ×1

arm ×1

boost ×1

c ×1

c# ×1

file ×1

i2c ×1

ioctl ×1

networking ×1

stl ×1

tcp ×1

wcf ×1