<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[TxT over UDP]]></title><description><![CDATA[<p dir="auto">Hello, I need to send several lines contained inside a TxT file, one at the time, over UDP. I am not very good at programming and would like someone to give me some advice. Thanks.</p>
<p dir="auto">I currently do this manually every time I need to. It will be great if I can make it automatically.</p>
]]></description><link>http://64.23.185.212/forum/topic/26/txt-over-udp</link><generator>RSS for Node</generator><lastBuildDate>Wed, 11 Mar 2026 13:43:48 GMT</lastBuildDate><atom:link href="http://64.23.185.212/forum/topic/26.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 16 May 2022 22:18:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to TxT over UDP on Thu, 02 Jun 2022 04:19:44 GMT]]></title><description><![CDATA[<p dir="auto">Thanks Vladimir!</p>
]]></description><link>http://64.23.185.212/forum/post/96</link><guid isPermaLink="true">http://64.23.185.212/forum/post/96</guid><dc:creator><![CDATA[Luis Ramírez]]></dc:creator><pubDate>Thu, 02 Jun 2022 04:19:44 GMT</pubDate></item><item><title><![CDATA[Reply to TxT over UDP on Tue, 31 May 2022 11:23:24 GMT]]></title><description><![CDATA[<p dir="auto">The <code>io.MappedFile</code> (<a href="https://vovkos.github.io/jancy/stdlib/class_io_MappedFile.html" rel="nofollow ugc">https://vovkos.github.io/jancy/stdlib/class_io_MappedFile.html</a>) provides a convenient and efficient way of accessing files -- especially in read-only mode.</p>
<p dir="auto">Instead of querying file size, then allocating a buffer, then reading the contents into this buffer -- the<code>io.MappedFile.view</code> method simply maps the requested region of the file and returns a pointer to the mapped region. Mapped files normally give more efficient access on both Windows and Unix (Linux/Mac). If the file is too big, you can sequentially call <code>io.MappedFile.view</code> for sub-regions of the file -- the management of mapped regions happens behind the scene.</p>
<p dir="auto">In our case, we asked to view a region at file offset <code>0</code>, <code>file.m_size</code> bytes long -- so the returned pointer can be used to access the whole file.</p>
<p dir="auto">A more traditional approach would look like:</p>
<pre><code>io.File file;
file.open(fileName, io.FileOpenFlags.ReadOnly);
void* p = new char[file.m_size];
file.read(p, file.m_size);

// work with p
</code></pre>
]]></description><link>http://64.23.185.212/forum/post/94</link><guid isPermaLink="true">http://64.23.185.212/forum/post/94</guid><dc:creator><![CDATA[Vladimir]]></dc:creator><pubDate>Tue, 31 May 2022 11:23:24 GMT</pubDate></item><item><title><![CDATA[Reply to TxT over UDP on Sat, 28 May 2022 00:24:04 GMT]]></title><description><![CDATA[<p dir="auto">I made a mistake with the file I was using. Everything is fine with the script. Thank you very much. This has saved me a lot of work.</p>
<p dir="auto">I am now very interested in how this script works. If you don't feel that I abuse your willingness, can you briefly explain how the script works? The operation of file.view is particularly confusing to me as I don't know whether the value of the pointer or the contents of the file is stored in "p".</p>
]]></description><link>http://64.23.185.212/forum/post/91</link><guid isPermaLink="true">http://64.23.185.212/forum/post/91</guid><dc:creator><![CDATA[Luis Ramírez]]></dc:creator><pubDate>Sat, 28 May 2022 00:24:04 GMT</pubDate></item><item><title><![CDATA[Reply to TxT over UDP on Thu, 26 May 2022 10:30:13 GMT]]></title><description><![CDATA[<p dir="auto">Just tried it with some local text file and it worked as expected:</p>
<p dir="auto"><img src="/forum/assets/uploads/files/1653560825877-392ea4ab-d151-4145-9e8e-5dff2d6769d3-image.png" alt="392ea4ab-d151-4145-9e8e-5dff2d6769d3-image.png" class=" img-responsive img-markdown" width="1045" height="790" /></p>
<p dir="auto">Could you please share some details about how exactly it doesn't work on your machine (a screenshot maybe)? Re delays -- delays might be necessary if the remote node isn't fast enough to process incoming UDP packets, but the script should send the file line by line regardless of the delays.</p>
]]></description><link>http://64.23.185.212/forum/post/90</link><guid isPermaLink="true">http://64.23.185.212/forum/post/90</guid><dc:creator><![CDATA[Vladimir]]></dc:creator><pubDate>Thu, 26 May 2022 10:30:13 GMT</pubDate></item><item><title><![CDATA[Reply to TxT over UDP on Wed, 25 May 2022 19:14:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi, it worked perfectly. It was suppose to send the lines one by one, but it doesn't. I set a delay at the end of the "while" however is not the solution. How can I solve it?</p>
]]></description><link>http://64.23.185.212/forum/post/89</link><guid isPermaLink="true">http://64.23.185.212/forum/post/89</guid><dc:creator><![CDATA[Luis Ramírez]]></dc:creator><pubDate>Wed, 25 May 2022 19:14:59 GMT</pubDate></item><item><title><![CDATA[Reply to TxT over UDP on Tue, 24 May 2022 08:46:59 GMT]]></title><description><![CDATA[<p dir="auto">Literals in Jancy, just like in C, use <a href="https://en.wikipedia.org/wiki/Escape_sequences_in_C" rel="nofollow ugc">escape-encoding</a> with <code>\</code> as the escape prefix. As such, the resulting path is incorrect.</p>
<p dir="auto">You can either:</p>
<ul>
<li>double-up the <code>\</code> characters (i.e., <code>"C:\\TMP\\script\\text.txt"</code>)</li>
<li>use the forward slash character <code>/</code> (i.e., <code>"C:/TMP/script/text.txt"</code>)</li>
<li>use a raw literal that won't apply escape-encoding (i.e., <code>r"C:\TMP\script\text.txt"</code>)</li>
</ul>
<p dir="auto">Hope this helps!</p>
]]></description><link>http://64.23.185.212/forum/post/88</link><guid isPermaLink="true">http://64.23.185.212/forum/post/88</guid><dc:creator><![CDATA[Vladimir]]></dc:creator><pubDate>Tue, 24 May 2022 08:46:59 GMT</pubDate></item><item><title><![CDATA[Reply to TxT over UDP on Tue, 24 May 2022 00:34:31 GMT]]></title><description><![CDATA[<p dir="auto">Thanks Vladimir!</p>
<p dir="auto">I set the path to my txt file and run the script. I know it found the file but I get this error:</p>
<p dir="auto">"Script transmit error:<br />
The filename, directory name, or volume label syntax is incorrect."</p>
<p dir="auto">File name syntax is in MS-DOS format. "file.open("C:\TMP\script\text.txt", io.FileOpenFlags.ReadOnly);"</p>
<p dir="auto">Text file looks like this:</p>
<p dir="auto">8308864495038423916F010201020000628C1DA7628C1DA705F37E4CCDD503B40000000000000000007410020004FFBF0F001Ea199030600000000000000106000000000001A35DF02C8026962347EF0<br />
8308864495038423916F010201020001628C1DA7628C1DA705F37E4CCDD503B40000000000000000007411020004FFBF0F001Ea199030600000000000000106100000000001B333702C8026A62347EF0</p>
<p dir="auto">...those are just two lines, the file has many more.</p>
<p dir="auto">What could I have done wrong?</p>
]]></description><link>http://64.23.185.212/forum/post/87</link><guid isPermaLink="true">http://64.23.185.212/forum/post/87</guid><dc:creator><![CDATA[Luis Ramírez]]></dc:creator><pubDate>Tue, 24 May 2022 00:34:31 GMT</pubDate></item><item><title><![CDATA[Reply to TxT over UDP on Mon, 23 May 2022 19:53:40 GMT]]></title><description><![CDATA[<p dir="auto">Hello Luis,</p>
<p dir="auto">You can achieve what you want with a simple script. Open the file, then iterate over its contents and transmit it line by line:</p>
<pre><code>import "io_base.jncx"
import "io_MappedFile.jnc"

void main() {
	connect(); // ensure the transport is connected

	io.MappedFile file;
	file.open("file-path", io.FileOpenFlags.ReadOnly);
	char const* p = file.view(0, file.m_size);
	char const* end = p + file.m_size;
	
	while (p &lt; end) {
		char const* nl = memchr(p, '\n', end - p);
		if (!nl) {
			if (p &lt; end)
				transmit(p, end - p);
			break;
		}

		transmit(p, nl - p + 1); // include \n
		// transmit(p, nl - p);  // omit \n
		p = nl + 1;
	}
}
</code></pre>
]]></description><link>http://64.23.185.212/forum/post/85</link><guid isPermaLink="true">http://64.23.185.212/forum/post/85</guid><dc:creator><![CDATA[Vladimir]]></dc:creator><pubDate>Mon, 23 May 2022 19:53:40 GMT</pubDate></item></channel></rss>