topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • October 23, 2018, 08:24 AM
  • Proudly celebrating 13 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kyrathaba [ switch to compact view ]

Pages: [1] 2 3 4 5 6 ... 121next
1
Developer's Corner / Need help tweaking C# server code
« on: September 21, 2018, 05:56 PM »
I have quoted a C# source code file that compiles fine. It runs a server on my local machine and listens for a connection. As the screenshot shows, I can connect to it successfully via telnet. However, the server is responding to each individual character I type in telnet, rather than waiting until I type a word or sentence and press Enter while in telnet. I know this has to be an easy fix, but I'm foggy right now.

The behaviors I'm looking for is for the server to receive multi-word phrases and echo them to the console. See source code and also the screenshot. I want to be able to type "quit" from telnet and have the server respond to that word, rather than each character.

using System;
using System.Reflection;
using System.IO;
using com.wms.strings;
using com.wms.io;
using System.Text;
using System.Net;
using System.Net.Sockets;

//https://codeabout.wordpress.com/2011/03/06/building-a-simple-server-client-application-using-c/

namespace MyProgramNamespace{
class Program{
static void Main(){

//insert code here...
string sAppPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
string sExeName = Path.GetFileName(Assembly.GetExecutingAssembly().GetName().CodeBase);
sAppPath = sAppPath.Substring(6, sAppPath.Length - 6);
string sFullPathToExe = sAppPath + "\\" + sExeName;

MyConsole.Entitle("Bryan Miller", "kyrathasoft@gmail.com", "ls44.exe");
Console.WriteLine(" Trying to initialize server...");

try{
IPAddress ipAdress = IPAddress.Parse("127.0.0.1");
TcpListener myList = new TcpListener(ipAdress,8000);
myList.Start();

Console.WriteLine("Server running - Port: 8000");   
Console.WriteLine("Local end point:" + myList.LocalEndpoint );
Console.WriteLine("Waiting for connections...");

Socket s = myList.AcceptSocket();
 
// When accepted
Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);
bool condition = true;

while(condition){
byte[] b = new byte[100];
int k = s.Receive(b);
Console.WriteLine("Received...");
string sMsgFromClient = string.Empty;
for (int i=0;i<k;i++)
{
sMsgFromClient += Convert.ToChar(b[i]).ToString();
}
Console.WriteLine(" Client sent: {0}", sMsgFromClient);
if(sMsgFromClient.Trim().ToUpper() == "QUIT"){ condition = false; }
ASCIIEncoding asen = new ASCIIEncoding();
s.Send(asen.GetBytes("Automatic message: " + "String received by server!"));
Console.WriteLine("\n Automatic message sent!");
}

s.Close();
myList.Stop();

}catch(Exception e){
MyConsole.WriteLine("Exception: " + e.Message );
}

MyConsole.Write("To exit ls44.exe, press any key...");
Console.ReadLine();
Console.WriteLine();
}
}
}

2
N.A.N.Y. 2019 / Re: My entry
« on: September 18, 2018, 06:30 AM »
Thanks, Ath. I wasn't as alert as I should've been when I made the OP. I've added the app's purpose to the OP.

3
N.A.N.Y. 2019 / My entry: A .NET Console Program Generator
« on: September 17, 2018, 08:19 PM »
I had so much going on that I wasn't able to participate in NANY 2018, so I'm getting this app in extra early, for NANY 2019.

Purpose: The cpg.exe program is a Windows command-line program that I developed because for several weeks now I've been writing a series of C# Console Programming tutorials on my local DokuWiki. Over the weeks, I've developed a pair of libraries, ioLibrary.cs and stringLibrary.cs, that I use frequently, almost with every new console program I create to illustrate a concept or test a new method. It became laborious  copying the two libraries' response files to the new program's directory each time, creating a custom response file for the new program itself, and creating a batch file to call all three three response files against the csc.exe command line compiler. Thus cpg.exe was created to automate all of that.

It's very handy for me, personally. If anyone would like, I can further develop it so that it is library-agnostic and creates the simplest possible console program.

Target Audience: C# console programmers.

Unzip the download, and place folder csdev at the root of C:\. Open an elevated command prompt in the same directory (or open the elevated prompt and navigate to cpg.exe).
cpg.exe is located in the /tools/ subdirectory. Run cpg.exe (stands for console program generator) and it will show you the use of its command-line syntax. Requires .NET Runtime.

Basically, the app is a Console Program Generator (hence, cpg.exe). When you run it and supply a path/to/desired/directory/mypreferredfilename
as a argument, it will create a C# console source code file at the specified location and will compile it.

Here's a screen shot of an executing test console app generated by cpg.exe:

cpg.PNG

The download should be extracted to your root drive on a Windows PC, i.e., C:\

That's where you should locate the /csdev/ folder after unzipping. Hey, I didn't know when I started this that I'd be sharing it,
so it's not very flexible as I coded it for my own use.

Currently, the program copies a couple of DLL libraries I wrote to the new source code file's directory. The library source code is included in the download. Also, when cpg.exe writes the source
to c:\what\ever\path\filename, it inserts the relevant using statements (equivalent of C++ includes), creates needed response files,and generates a batch file to make repetitive command line builds fast. The cpg program itself has had ioLib.dll and strLib.dll merged with its own assembly via ILMerge tool.


4
General Software Discussion / Question about console programming in C#
« on: September 11, 2018, 05:03 PM »
I've been writing many small console programs via the command-line C# compiler. My question is: is there any particular reason why I shouldn't use the -nowin32manifest switch when compiling? It makes the .exe smaller, but is there a downside for me? Remember these are just handy little programs I use myself or have written to illustrate some concept. Nothing commercial or anything.

5
Thanks x16wda and Mark0

6
Thanks, KodeZwerg.

I've got a pretty decent grasp of the code. What I'm looking for are examples of Windows CLI programs whose output it could be useful to capture from within another program.

7
Thanks, Ath! Appreciate it.

8
So, for the last few weeks I've been writing a book (via my private DokuWiki and simultaneously in .epub and .prc formats) about some of the things I've learned to do with C# over the last decade. I'm at a place in the book where I show how to capture output from some other process that is initiated by my C# app. I'm looking for a couple of Windows command-line programs that are complex enough to yield data not just-as-easily-derived by the calling application. It's okay if the C# app needs to do some string parsing, etc., with the returned data. I'm just wanting to give a good example of not re-inventing the wheel.

9
I wound up uninstalling Gridinsoft Anti-malware. I sent a few of its identified threats to Jotti and got the green light, so... Same thing with VirusTotal.

10
^ Yeah, I've always thought ClamWin was a bit over-eager. It identified Macrium Reflect as malware ;)

11
Thanks, Shades. I'll check out that link...

12
General Software Discussion / Gridinsoft Antimalware's reputation?
« on: August 25, 2018, 10:30 AM »
I've run a scan with Gridinsoft Antimalware 4.0.7.226 on my laptop and of 100,339 files, it's showing 3,074 "threats" and 3 PUPs. However, the result of a scan via AntiMalwareBytes Premium 3.5.1 indicates zero threats.

Also, anyone else use 3uTools on Windows to manage iPhone storage? ClamWin thinks it contains a worm and a trojan agent.

13
Living Room / Re: The Movie and Book Writing Thread
« on: July 24, 2018, 10:36 AM »
No, I'm generating an epub with Pandoc. It highlights code listings appropriately but it doesn't show line numbers in the code listings of the produced epub. Wondering if there's a way to do that.

14
Living Room / Re: The Movie and Book Writing Thread
« on: July 24, 2018, 09:50 AM »
I have a Pandoc question. I'm wanting to produce some documentation in epub format. There are some listings of C# code, and I want to show line numbering in those code listings. Anyone know how this is done?

15
I understand from the documentation that even if someone guessed the URL to a private WordPress post, they still couldn't view it. Is that strictly true? How vulnerable are private posts to, say, a WordPress site using say a typical security plug-in like Wordfence?

16
Living Room / WordPress question
« on: June 18, 2018, 11:54 AM »
I have my WordPress site set so that it shares my posts to FaceBook and other social sites. Is there a way (perhaps a plug-in, or a post option I've overlooked) to selectively choose NOT to have a given post shared to these other sites?

17
I'm with Edvard and Deozaan. I REALLY like Brave.

braveBrowser.png

18
Thanks @tomos and @skwire

19
Perfect! Thanks, Shades and wraith808!

20
I'm looking for two softwares.

The first is a free CLI tool built on top of jsNode that can encrypt one or more HTML pages, requiring a password to open them. I know this exists but can't remember the name of the tool.

The other I'm looking for is software that switches the Desktop wallpaper among images in a folder (in sequence or randomly) at user-selectable intervals. I think someone coded this for one of the N.A.N.Y.s, but I can't recall the user or name of the program.

21
N.A.N.Y. 2018 / Re: NANY 2018 Release: Proofy
« on: January 17, 2018, 12:18 PM »
Additional functionality added: current distribution is distro #9

22
N.A.N.Y. 2018 / Re: NANY 2018 Release: Proofy
« on: January 14, 2018, 02:50 PM »
Some new functionality; fixed code logic to address a couple of edge cases. Current distro is: #8

23
N.A.N.Y. 2018 / Re: NANY 2018 Release: Proofy
« on: January 13, 2018, 10:57 AM »
Couple of bug fixes and enhancements. Current distro is: #7

24
 :Thmbsup: :Thmbsup: :Thmbsup:

25
N.A.N.Y. 2018 / Re: NANY 2018 Release: Proofy
« on: January 07, 2018, 09:11 PM »
Yep, there was a bug in the method that calculated those values. Check distro6 for the fix. Now Proofy counts any project's initiation date when considering that range. See top left red circle. The bottom-right red circle shows that Proofy calculates total words proofed in the current year thus far. I will be adding breakdown-by-year of words-proofed, just as I've already done for earnings per year.

@Ath:

proofy7.png

Pages: [1] 2 3 4 5 6 ... 121next