Re: Problem sending binary file by socket never ending.
I found the problem. The server must not use the buffering mode otherwise it waits that buffer is full. var server = newAsyncSocket(buffered=false) Run Thanks
Re: Problem sending binary file by socket never ending.
I can do that but my binary files can be very big.
Re: Problem sending binary file by socket never ending.
Thank you for the idea to send the file size :) I modified the code to receive the file size et I add a counter of byte. But the server never get last data. I think that the server waits a buffer of size **4000**. The Client: import net, streams, os let client: Socket = newSocket() client.connect("127.0.0.1", Port()) stdout.writeLine("Client: connected to server on address 127.0.0.1:") while true: stdout.write("> ") let filename: string = stdin.readLine() var data = newString(4000) let file = open(filename, fmRead) let size = getFileSize(file) echo "File size is :" & $size echo "Send file size" client.send($size & "\c\L") echo "Pull ..." sleep(100) while true: let len = file.readBuffer(addr(data[0]), 4000) setLen(data, len) if len == 0: break else: echo "Send data size : " & $len client.send(data) echo "End of file" file.close() client.close() Run The Server import asyncnet, asyncdispatch, parseutils proc processClient*(client: AsyncSocket) {.async.} = var fileSize: int counter: int while not client.isClosed: echo "Wait file" var file = open( "receive.7z", fmWrite ) let sizeFileString = await client.recvLine() discard sizeFileString.parseInt(fileSize) echo "File Size is " & $fileSize counter = 0 var dataFut = client.recv(4000) while true: yield dataFut echo "Counter : " & $counter if counter >= fileSize: break else: if dataFut.finished: let data = dataFut.read if data != "": counter += data.len file.write(data) dataFut = client.recv(4000) else: echo "No data" break else: echo "Exit" break echo "End of file" file.close client.close() proc serve() {.async.} = var server = newAsyncSocket() server.setSockOpt(OptReuseAddr, true) server.bindAddr(Port()) server.listen() echo "Server run !" while true: let client = await server.accept() echo "Connect client" asyncCheck processClient(client) asyncCheck serve() runForever() Run Have you any idea ?
Problem sending binary file by socket never ending.
Hello, I'm a problem to send binary file over socket. I would like send file but without close the connection, it's important. The problem is that server never close the file because it wait for ever a data. I wrote an example: Client: let client: Socket = newSocket() client.connect("127.0.0.1", Port()) stdout.writeLine("Client: connected to server on address 127.0.0.1:") while true: stdout.write("> ") let filename: string = stdin.readLine() echo "Pull ..." var data = newString(4000) let file = open(filename, fmRead) while true: let len = file.readBuffer(addr(data[0]), 4000) setLen(data, len) if len == 0: echo "Send end" client.send("\c\L") break else: client.send(data) echo "End of file" file.close() client.close() Run Server import asyncnet, asyncdispatch proc processClient*(client: AsyncSocket) {.async.} = while not client.isClosed: echo "Wait file" var file = open( "receive.7z", fmWrite ) var dataFut = client.recv(4000) while true: yield dataFut if dataFut.finished: let data = dataFut.read if data != "": file.write(data) dataFut = client.recv(4000) else: echo "No data" break else: echo "Exit" break echo "End of file" file.close client.close() proc serve() {.async.} = var server = newAsyncSocket() server.setSockOpt(OptReuseAddr, true) server.bindAddr(Port()) server.listen() echo "Server run !" while true: let client = await server.accept() echo "Connect client" asyncCheck processClient(client) asyncCheck serve() runForever() Run How I can send an EOF ? I tried "cL" or an empty string without success. Thanks.
Re: Looking for contributions to my optimistic image library
@mratsim I agree with you but I'm a little frustate because I love Nim and in my job I use OpenCV. I would like use both in my free time :( The binding is not the best choice especially if it is not official but it allows developpers of others languages to reuse his favorit library (when the binding works well). It is easier to use a language when you can use popular library or similar but that's another debate. Nim is young, ecosystem grows up and welcome inumon.
Re: Looking for contributions to my optimistic image library
Hello. @Voltist, thanks for this library in pure Nim to open Jpeg and PNJ file and made some simple manipulation. If your objective is to made a big lib there is a wrapper for OpenCV ([https://github.com/dom96/nim-opencv](https://github.com/dom96/nim-opencv)) and for me it a better idea to make every effort required for improve compatibility. OpenCV is very used in computer vision and machine learning, it's a reference in this field. OpenCV is already bind in Java, Python and Javascript, why not Nim.
Re: Hackathon as part of NimConf 2020
I agree with @spip for the problem of documentation because a lot of function aren't comments but for me there is also a problem of useful small libraries. It's normal, Nim is young. I lost a lot of time to develop some useful utils to extract/compress archive, download files from url, etc. The Hackathon can propose to develop basics libraries to do : * extract and create archive in all formats (see [https://github.com/wummel/patool](https://github.com/wummel/patool)) * very simple file downloader (see [https://bitbucket.org/techtonik/python-wget/](https://bitbucket.org/techtonik/python-wget/)) * a simple REAST Framework (see [http://pistache.io/](http://pistache.io/)) For web developers, a other idea is to fix issues and improve [https://nimble.directory/](https://nimble.directory/).
Re: Nim 1.0.6 is out!
Yes me too, the next version with minor change published should be normaly 1.1.0 or 1.1.2 now that the 1.1.1 version already exists.
Re: Nim 1.0.6 is out!
Thank for the link. I didn’t know this version process and I’m not the only.
Re: Nim 1.0.6 is out!
Yes explain me why patches version are incremented every time by 2, there is certainly a logic behind this. And the minor version are incremented by 1 (0.19.6 -> 0.20.0) or it has changed since v1.0.0 ?
Re: Nim 1.0.6 is out!
I don’t understand why the next version will be 1.2 whereas the version 1.1.1 hasn’t been published officially.
Re: Get first element in Table
I don't use the Table object properly. I'm going to change my data structure. Thank you.
Get first element in Table
Hello everyone, How to get the first element in a Table ? My example : import tables var a = {1: "one", 2: "two"}.toTable echo a.keys[0] Run The result, for me, should display **1**. Thanks.
Re: Make Nim easier for the developer
The word "popular" is maybe a bad word and I can understand that somebody can disagree with it. @edu500ac, you are passionate of Lisp and I understand that you are heap up when a guy say that a good language is a popular language. Lisp is certainly a good language and as you say lot of great applications or libraries was developed with it. But I'm an industrial developer and I create architecture and develop code for embedded board where the performance and an perfect memory management is primordial. We use C/C++ and my scientist co-workers use MatLab and Python to develop and test algorithm quickly. And my clients need code in C and C++ especially when your program must works in autonomous car or in a space robot like ExoMars. Then yes, COBOL, Fortran, Pascal etc are maybe great languages but they don't support all platforms or architectures and few people know them in my field of work. Languages change, evolve and sometime disappear, now CNRS use Python instead of Scilab/Matlab to make scientific algorithms and some big companies (Electronic Arts, Red Hat) use RUST instead of C++. Why not Nim ? I like Nim because I can write easily my code and it offers me the capability to use my libraries in C++ in my personal project. Maybe one day in my work or never. Thank you @mratsim for nimterop, I'll try it with OpenCV. Use GDB in Windows in not a solution because when I work on Windows then I use the Visual C++ compiler and never mingw. Yes only 3 paid full-time developers working on Nim and it's pity but I prefer this rather than a big company behind a language like Sun with Java.
Make Nim easier for the developer
Hello everyone, I use several languages in my work and with big libraries (OpenCV, GDAL). My main language is C++, I use Python to script and sometime Julia. I'm using Nim from 4 weeks for a personal project and I love it. I didn't write this post to talk about me but the future features that must be developed in Nim to become a main language like C/C++. Every year or mouth maybe a new language is created with lots of features to create everything, easy to learn/read/write, efficient ... but only some new languages gain popularity. For me the features missing in Nim are by priority order: 1\. C/C++ auto binding : A new programing language must propose a binding solution with an other language or ecosystem with lot of packages developed during several years and maintained. All new languages has their compiler and propose a binding feature often with C and sometime C++. But in my case, who going to develop a complete binding of very big library ? I use OpenCV and I don't want to change it by an other. There is a binding in GitHub ([https://github.com/dom96/nim-opencv](https://github.com/dom96/nim-opencv)) but it isn't maintained since 2017. This is the main problem. Nim use C/C++ compilers like GCC and it's a great idea. Thanks to this particularity, the developer should be able to use easily a library without develop a binding and it must be done by the language. A good example is Julia that can call Python code directly in its code with the import keyword "pyimport". For Nim, I don't know how, maybe with a file descriptor to define include files and library path but without define functions and types binding. It's a big job but necessary for me. 2\. Debugging tool : Nim code is compiled with several compilers but this implies using different debugger. I know well GDB but in Windows I never used Microsoft's debugger because I use an IDE. Furthermore, in my IDE the debugging commands are the same on Windows, Mac and Linux. I'm not saying that should create a wrapper to all debuggers but this work should be done by the IDE. 3\. A great IDE : We can write our code with all editors like Vim or Notepad++ but they are only text editors. Un great language has a great IDE but it is useless to create an other editor only for Nim. For me the best solution is to choose an existing editor and create an plugin for it. I talk about Atom and VSCode, I use VSCode for all my development and a good plugins for Nim already exist. The problems are that the last version was published in February, the development is slow and there isn't a support for the debugging. This plugins should be managed by Nim (in the Nim repository) and a team should be focused on improving it. It's my opinion and I'm not saying that will be easy but Nim has been released and lot of curious people will want to use it. It's better if it's easy. You can develop the best GC in world but if the language is hard to use then few developers will use it. Now you should think developer-friendly. Thank you for reading me and sorry for my bad English.