|
Hello Richard,
Thanks for your reply.
First two session in earlier post is the code from sender. Here are the code for the functions mentioned in the thread.
public void readFromReceiver(object clients)
{
ASCIIEncoding encoder = new ASCIIEncoding();
TcpClient client = (TcpClient)clients;
NetworkStream clientStream = (client).GetStream();
byte[] msg_type = new byte[1];
bool flag = false;
while(!flag)
{
try
{
int bytesRead = 0;
bytesRead = clientStream.Read(msg_type, 0, 1);
int msg = (int)(msg_type[0]);
string retVal = "";
if (msg == 3)
{
retVal = receiveString(clientStream);
}
}
catch(Exception ex)
{
}
}
}
public void writeToReceiver(object clients)
{
ASCIIEncoding encoder = new ASCIIEncoding();
TcpClient client = (TcpClient)clients;
NetworkStream clientStream = (client).GetStream();
bool flag = false;
while(!flag)
{
while (nQReceiveProjName.Count > 0)
{
try
{
string cmdToPass = fnGetXMLString(nQReceiveProjName[0]);
nQReceiveProjName.RemoveAt(0);
sendCommand(clientStream, 5);
sendString(clientStream, cmdToPass);
}
catch(Exception ex)
{
}
}
}
}
In both the cases, client remote end point is holding the ip address of the client in which the first request is received.
Regards,
Gopinath.
|
|
|
|
|
I don't see anything anywhere where you are storing or using an IP address. Once a socket connection is established between server and client, that socket remains open until closed by either end. Each message using the correct socket endpoint will be sent to the correct client. Google for "client server C#" to see other examples.
|
|
|
|
|
Here is where I am using the ip address to send the request.
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip_address), portNo);
client.Connect(serverEndPoint);
Let me check in google also as you mentioned.
Thanks again.
Regards,
Gopinath.
|
|
|
|
|
You only do that once, when the client first connects. From then on you must use just the socket that is returned on the connection.
|
|
|
|
|
Hello Richard,
There was an issue from my side. While sending the request (writetosender() function), I am not segregating the request according to the client.
Now it is fixed and working fine.
Thanks again.
Regards,
Gopinath.
|
|
|
|
|
I am getting this error:Severity Code Description Project File Line Suppression State
Error Invalid Resx file. Could not load type System.Collections.Generic.List`1[[Spring_2018_New_List_View_Macro_Box_Tester.LineItemData, Spring 2018 New List View Macro Box Tester, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 which is used in the .RESX file. Ensure that the necessary references have been added to your project. Line 133, position 5. Spring 2018 New List View Macro Box Tester C:\Users\\Desktop\C prog\Spring 2018 New List View Macro Box Tester - Copy (4) - Copy\Spring 2018 New List View Macro Box Tester\Form1.resx 133
This is the resx file. Can anybody tell me what is wrong?
Note: I only get this error after I do anything with the form that the custom user control is on.
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="mbListView1.LineList" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAALABU3ByaW5nIDIwMTggTmV3IExpc3QgVmlldyBNYWNybyBCb3gg
VGVzdGVyLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVs
bF1dLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRv
a2VuPWI3N2E1YzU2MTkzNGUwODkMAwAAAGFTcHJpbmcgMjAxOCBOZXcgTGlzdCBWaWV3IE1hY3JvIEJv
eCBUZXN0ZXIsIFZlcnNpb249MS4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1u
dWxsBQEAAABaU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tTcHJpbmdfMjAxOF9OZXdf
TGlzdF9WaWV3X01hY3JvX0JveF9UZXN0ZXIuTGluZUl0ZW1EYXRhAwAAAAZfaXRlbXMFX3NpemUIX3Zl
cnNpb24EAAA5U3ByaW5nXzIwMThfTmV3X0xpc3RfVmlld19NYWNyb19Cb3hfVGVzdGVyLkxpbmVJdGVt
RGF0YVtdAwAAAAgIAgAAAAkEAAAAAAAAAAAAAAAHBAAAAAABAAAAAAAAAAQ3U3ByaW5nXzIwMThfTmV3
X0xpc3RfVmlld19NYWNyb19Cb3hfVGVzdGVyLkxpbmVJdGVtRGF0YQMAAAAL
</value>
</data>
</root>
|
|
|
|
|
Your project is "confused"; you need to clean it up ... literally.
C:\Users\Desktop\C prog\Spring 2018 New List View Macro Box Tester - Copy (4) - Copy\Spring 2018 New List View Macro Box Tester\Form1.resx 133
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I had been working on a program for quite some time. For some reason, though the code was running, the design mode got screwed up. There are several errors.
1. One of my custom controls no longer seems to have design mode available at all. It now just looks like C# code and not a custom control and when I double-click on it in the solution explorer no design mode comes up.
2. Another user control (that makes use of the previous control mentioned) cannot be changed on the main form at all. When I try to edit or even delete it I get this error:
"An error occurred while processing this command: Type 'Spring_2018_New_List_View_Macro_Box_Tester.lineItemData' in Assembly 'Spring 2018 New List View Macro Box Tester, Version 1.0.0.0, Culture = neutral, PublicKeyToken=Null' is not marked as serializable."
And under output I get "The program '[16676] Spring 2018 New List View Macro Box Tester.exe: Program Trace' has exited with code 0 (0x0).
The program '[16676] Spring 2018 New List View Macro Box Tester.exe' has exited with code 0 (0x0).
Thanks,
FC
|
|
|
|
|
The "project properties" of a file can get fouled; causing the "Designer" to have issues.
Sometimes you can just "add" the "item" back as an existing item.
Sometimes you have to create a "new" control and paste your existing code back in.
I've had 3rd party projects that refused to honor my "text formatting rules" until I "rebuilt" some files.
A project file "fix" may help; but can also make the entire project (file) unusable if done wrong.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I need help creating a class file that randomly generates a number of 10 characters, 0-9, A-Z. By generating a PIN it will create an authorization workflow to allow the user to authenticate the app. This number will be directed to a config file instead of a URL. The user goes thru a auth process and instead of calling back a URL there will be a page to randonly generate a pin. The randomly generated PIN will be stored in a database table.
For the database columns would get set properties be the best approach for each column in that table? Would this be the best approach for REST API? I am not very familiar with API's. Something like this
public class AuthorizationPIN
{
public int Id { get; set; }
public string AccessCode { get; set; }
public string PIN { get; set; }
}
|
|
|
|
|
You show one small component (of a larger process) and ask for "opinions".
At this point, it is neither right nor wrong.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Another smarmy smartass. Wow you are you f***ing dumb. I don't have any other code besides what I posted. I don't know where to begin with code to generate a PIN number that's why I asked!
F*** off a**hole seriously. I don't want to hear it from the moderators. There is no excuse for responding to me the way this guy responded to me. None!
|
|
|
|
|
|
And with a response like that you are hoping for support from a bunch of volunteers. If you don't like the response he gives you then ignore him as you will probably be ignored in the future.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello,
I have a probleme with the animation of my caracter. The animation run when my caracter stay put. I use Unity3D
<br />
using System.Collections;<br />
using System.Collections.Generic;<br />
using UnityEngine;<br />
<br />
public class PlayerMove : MonoBehaviour {<br />
<br />
private Animator anim;<br />
private CharacterController charController;<br />
private CollisionFlags collisionFlags = CollisionFlags.None;<br />
<br />
private float moveSpeed = 5f;<br />
private bool canMove;<br />
private bool finished_Movement = true;<br />
<br />
private Vector3 target_Pos = Vector3.zero;<br />
private Vector3 player_Move = Vector3.zero;<br />
<br />
private float player_ToPointDistance;<br />
<br />
private float gravity = 9.8f;<br />
private float height;<br />
<br />
void Awake () {<br />
anim = GetComponent<Animator> ();<br />
charController = GetComponent<CharacterController> ();<br />
}<br />
<br />
void Update () {<br />
MoveThePlayer ();<br />
charController.Move (player_Move);<br />
<br />
}<br />
<br />
void MoveThePlayer() {<br />
if (Input.GetMouseButtonDown (0)) {<br />
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);<br />
RaycastHit hit;<br />
<br />
if (Physics.Raycast (ray, out hit)) {<br />
if(hit.collider is TerrainCollider) {<br />
<br />
player_ToPointDistance = Vector3.Distance (transform.position, hit.point);<br />
<br />
if (player_ToPointDistance >= 1.0f) {<br />
canMove = true;<br />
target_Pos = hit.point;<br />
}<br />
}<br />
<br />
}<br />
<br />
<br />
<br />
}<br />
<br />
if (canMove ) {<br />
anim.SetFloat ("Walk", 1.0f);<br />
<br />
Vector3 target_Temp = new Vector3 (target_Pos.x, transform.position.y, target_Pos.z);<br />
<br />
transform.rotation = Quaternion.Slerp (transform.rotation,<br />
Quaternion.LookRotation (target_Temp - transform.position),<br />
15.0f * Time.deltaTime);<br />
<br />
player_Move = transform.forward * moveSpeed * Time.deltaTime;<br />
<br />
if(Vector3.Distance (transform.position, target_Pos) <= 0.5f) {<br />
canMove = false;<br />
}<br />
<br />
} else {<br />
player_Move.Set (0f, 0f, 0f);<br />
anim.SetFloat ("walk", 0f);<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
If someone can help me I would be grateful
|
|
|
|
|
Too many "if's".
Just "move" in the Update to test that you can actually "move"; then add the "if's".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
hello
i want to edit a file by c# string by this code
string text = File.ReadAllText(@"c:\a.txt", Encoding.UTF8);
string text1 = text.Replace("xx", XX");
File.WriteAllText(@"d:\a.txt", text1);
i want to search in string and when find example replace exam\ple and 4 word after exam\ple with exam\plexxxx
problem is i dont know what is the 4 word and i want replace.
i want any like * in windows seach.
in windows search * can support all character.
|
|
|
|
|
There is no wildcard support in the Replace method. You're going to have to write your own code to do search and replace with support for wildcards.
|
|
|
|
|
Sounds to me like a case for Regular expressions[^] Google will have lots of help.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Get the ".IndexOf" your "keyword".
Then "string.Split" the rest into tokens / words; delimited by space, coma, etc.
The first 4 tokens are your "any character words".
Replace that part of the string between the "keyword" and the last word.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Looks like homework to me. And I suspect (and hope) the teacher has been teaching you something and that something is how you are supposed to be doing this.
|
|
|
|
|
i want to to write a program to correct program by edit one of bad file
|
|
|
|
|
That's different: in that case you definitely need a different approach. Reading and treating an executable file as text will corrupt the file; what you end up with is not going to be a valid executable, because the "translation" from the on-disk binary to text loses information, and the when you write it that cannot be recovered.
You would need to read the file as binary, handle it as binary, and write it back as binary as well.
But you also don't want to use the root folder of any drive: the access is restricted and likely to become more restricted in future.
Why do you think a program has a "bad file" that a simple text replace will fix?
Sent from my Amstrad PC 1640
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
my file is text file and not executable
this text file edit by program every run it but i want change one number after "id-number="
i dont know id-number in file but i want to change by my id number.
|
|
|
|
|
If you don't know the number you are replacing, then you need to look closely at the file, and check that the sequence "id-number=" only appears where you want to change it - that looks like a XML or config file and it's not guaranteed to have just a single occurrence.
But changing that is a text file is trivial: a basic regex will do it:
public static Regex regex = new Regex(
"(?<=id-number=)\\d+",
RegexOptions.IgnoreCase
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);
public static string regexReplace = "98765";
...
string result = regex.Replace(InputText,regexReplace);
Sent from my Amstrad PC 1640
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|