Posts

Server crashes after closesocket

I have multithreading application, it's periodically polling a few hundred devices. Each thread serves one device, its socket and other descriptors are encapsulated at individual object, so no shared descriptors. Occasionally application crashes after closesocket(fSock), when I try set descriptor fSock to 0. I assume, I should not set fSock = 0, if closesocket(fSock) returns SOCKET_ERROR. Or is there any other reason? My code: bool _EthDev::Connect() { int sockErr, ret, i, j; int szOut = sizeof(sockaddr_in); // create socket if ((fSock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { sockErr = GetLastError(); Log("Invalid socket err %d", sockErr); fSock = 0; return false; } // set fast closing socket (by RST) linger sLinger; sLinger.l_onoff = 1; sLinger.l_linger = 0; if (sockErr = setsockopt(fSock, SOL_SOCKET, SO_LINGER, (const char FAR*)&sLinger, sizeof(linger))) { ...

.NET File.WriteAllLines leaves empty line at the end of file

When I'm saving content of the String[] array with System.IO.File.WriteAllLines, at the end of a file is always left a blank line. For example: System.IO.File.WriteAllLines(Application.dataPath + "/test.txt",["a", "b", "c"]); Produces file (without underscore): a b c _ There was already such topic: Empty line in .Net File.WriteAllLines, is a bug? , but autor said that "I think there are something wrong with my data,that's my problem but not the WritAllLines" and it was closed as "too localized" (?!?). It's a bug? How can I easily get rid of it (for now I'm just ignoring it when reading file again)? Solved The WriteAllLines method will write out each line in your array followed by a line break. This means that you will always get this "empty line" in your file. The point made in the post you linked is that when running ReadAllLines that considers a line to be characters terminat...

How can I update multiple items with a shared customer number on a sharepoint list with AJAX?

I am trying to update a sp list with the following javascript/ajax. It succeeds until it gets to the ajax function, which is where it fails. It says the ItemID is not defined, when it is defined as: var ItemId=item.ID Any help appreciated. What I'm trying to do: I am trying to update all records in a list where the cust_number (a column in the list) field is 17 so that assign (another column) = "testinput". eg: Cust Number| Assign 17 | testinput 1 | 17 | testinput Solved I'm afraid you made a simple typo. On a certain point in your code you declare the following: var itemId = item.ID; Later on you try to acces that same variable url:_spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items('" + ItemId + "')", However itemId != ItemId Javascript is case sensitive.

OpenCV return keypoints coordinates and area from blob detection, Python

I followed a blob detection example (using cv2.SimpleBlobDetector ) and successfully detected the blobs in my binary image. But then I don't know how to extract the coordinates and area of the keypoints. Here are the code for the blob detections: # I skipped the parameter setting part. blobParams = cv2.SimpleBlobDetector_Params() blobVer = (cv2.__version__).split('.') if int(blobVer[0]) So the variable keypoints_black contains the information of the blob(s). When I printed the variable it looked something like this (2 blobs were found): KeyPoint 0x10b10b870, KeyPoint 0x10b1301b0 So how to I get the coordinates of the centre of mass of the keypoints and their area so that I can send them as osc messages for interaction. Solved The pt property: keypoints = detector.detect(frame) #list of blobs keypoints x = keypoints[i].pt[0] #i is the index of the blob you want to get the position y = keypoints[i].pt[1] Some documentation ...