af

套接字联网相关的函数调用

為{幸葍}努か 提交于 2019-12-03 20:27:17
socket函数 int socket(int protofamily, int type, int protocol); //返回sockfd,即描述符 功能 : socket 函数对应于普通文件的打开操作。普通文件的打开操作返回一个文件描述字,而 socket() 用于创建一个 socket 描述符(socket descriptor),它唯一标识一个 socket。这个 socket 描述字跟文件描述符一样,后续的操作都有用到它,把它作为参数,通过它来进行一些读写操作。 参数 : protofamily:即协议域,又称为协议族(family)。常用的协议族有,AF_INET(IPV4)、AF_INET6(IPV6)、AF_LOCAL(或称 AF_UNIX,Unix域socket)、AF_ROUTE等等。协议族决定了socket的地址类型,在通信中必须采用对应的地址,如 AF_INET 决定了要用 ipv4 地址(32位的)与端口号(16位的)的组合、AF_UNIX 决定了要用一个绝对路径名作为地址。 type:指定 socket 类型。常用的 socket 类型有,SOCK_STREAM、SOCK_DGRAM、SOCK_RAW、SOCK_PACKET、SOCK_SEQPACKET等等。 protocol:故名思意,就是指定协议。常用的协议有,IPPROTO_TCP

每日一题_191107

安稳与你 提交于 2019-12-03 17:31:51
已知 \(F_1,F_2\) 分别是双曲线 \(C:\dfrac{x^2}{a^2}-\dfrac{y^2}{b^2}=1\) \((a>0,b>0)\) 的左,右焦点,过 \(F_1(-2,0)\) 的直线与双曲线 \(C\) 的左支交于 \(A,B\) 两点,若 \(D\left(-\dfrac{1}{2},\dfrac{5}{8}\right)\) 为 \(\triangle ABF_2\) 的内切圆的圆心,则该内切圆的半径为 \((\qquad)\) \(\mathrm{A}.\dfrac{\sqrt{41}}{8}\) \(\mathrm{B}.\qquad\dfrac{3}{2}\) \(\mathrm{C}.\qquad\dfrac{13}{8}\) \(\mathrm{D}.\qquad\dfrac{5\sqrt{17}}{8}\) 解析: 过 \(D\) 作 \(DH\perp AB\) ,垂足为 \(H\) ,则 \[ |AF_2|-|BF_2|=|AH|-|BH|.\] 又 \[ \begin{cases} & |AF_2|=|AF_1|+2a,\\ & |BF_2|=|BF_1|+2a, \end{cases} \] 所以 \[ |AF_2|-|BF_2|=|AF_1|-|BF_1|,\] 于是 \[|AH|-|BH|=|AF_1|-|BF_1|.\] 因此

cp: missing destination file operand after

匿名 (未验证) 提交于 2019-12-03 08:59:04
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Im trying to do a full back up and copy over all files from one directory into another directory #!/bin/bash #getting files from this directory PROJECTDIRECTORY=/../../Project3 #Copied to this directory FILEBACKUPLOCATION= /../.../FMonday for FILENAME in $PROJECTDIRECTORY/* do cp $FILENAME $FILEBACKUPLOCATION done But I keep getting this error ./fullbackup: line 6: /../../FMonday: Is a directory cp: missing destination file operand after 回答1: I think this is what you need is FILEBACKUPLOCATION=/FMonday/ 回答2: Variable assignments in bash

CakePHP preserving validation errors after redirecting

匿名 (未验证) 提交于 2019-12-03 08:59:04
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an element which displays a comment form, the action is comments/add. If the form doesn't validate, I don't want users to go to comments/add (the view for which does not exist), but I want them to remain on the same page and see the validation errors there. However, redirecting to $this->referer() doesn't work - the validation errors disappear and just the flash message remains. public function add(){ if (!empty($this->data)){ $this->Comment->create(); if ($this->Comment->save($this->data)){ $this->Session->setFlash('Comment added.',

How to multicast with ipv6 udp socket in C/C++ on linux?

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: (English is not my native tongue, don't worry if some sentences are strange ;) ). I was developing a PONG game and by the way creating some classes to help me managing window, event ... and network because I added a LAN feature to the game but currently you have to enter the address of the one with who you want to play with. And a solution to that was a broadcast (scanning LAN for player) . This was easy with ipv4, just use the address 255.255.255.255 but we are in 2017 and provide a feature that works only with ipv4 sucks... Then I look for

What is the difference between AF_INET and PF_INET in socket programming?

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 选择语言 中文(简体) 日语 英语 中文(繁体) 由 翻译 强力驱动 问题: What is the difference between AF_INET and PF_INET in socket programming? I'm confused between using AF_INET and PF_INET in socket() and bind() . Also, how to give ip-address in sin_addr field? 回答1: Beej's famous network programming guide gives a nice explanation: In some documentation, you'll see mention of a mystical "PF_INET". This is a weird etherial beast that is rarely seen in nature, but I might as well clarify it a bit here. Once a long time ago, it was thought that maybe a address family (what the

Microsoft.DotNet.Web.targets missing after installing .NET Core RTM

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: We are migrating our project to .NET Core and I'm uppgrading our build server following the steps presented on this page https://www.microsoft.com/net/core#windows . After intalling VS 2015 update 3 and DotNetCore.1.0.0-VS2015Tools.Preview2 and building the project I get an error saying: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet.Web\Microsoft.DotNet.Web.targets" was not found. I checked the build server and sure enough the DotNet.Web folder which should be found at C:\Program Files

OpenGL invalid framebuffer operation after glClear(GL_COLOR_BUFFER_BIT);

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Every time after I call glClear(GL_COLOR_BUFFER_BIT); , I get the OpenGL error "invalid framebuffer operation". The call seems to work just fine, and nothing seems wrong. I call glClear(GL_COLOR_BUFFER_BIT); first thing in the ::paintGL() method. Huh? Should I just disregard this error? 回答1: My best guess is that your framebuffer is not complete and calling glClear on an incomplete framebuffer is throwing the error. Check the status of the framebuffer using glCheckFramebufferStatus and make sure it returns GL_FRAMEBUFFER_COMPLETE . 回答2: I

Explain how the AF flag works in an x86 instructions?

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a little 8086 emulator and I've had a long standing bug for like 2 years now that AF does not behave properly inside of sub and add instructions. My current way of computing its value is this for 8 bit numbers and subtraction: uint8_t base=... , subt=... base=base&0xF; subt=subt&0xF; //isolate bottom nibble if((int16_t)base-subt>7 || (int16_t)base-subt<-7){ flags.af=1; }else{ flags.af=0; } (assuming an instruction like sub base,subt ) And for adding it's like this: uint8_t base=... , adder=... base=base&0xF; adder=adder&0xF; //isolate

Camera2 API AutoFocus with Samsung S5

匿名 (未验证) 提交于 2019-12-03 03:00:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm working with the new Camera2 API on a Samsung S5. The supported hardware level this device is reporting is LEGACY , which is fine. However, I cannot seem to be able to auto-focus on this device. The request to trigger auto-focus looks like this: previewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO); previewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START); state = STATE_PREVIEW; try { captureSession.setRepeatingRequest(previewRequestBuilder.build(),