Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

108 Neutral

About jt.tarigan

  • Rank

Personal Information

  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi, I'm currently developing a client C# (Unity) based application communicating with a C based server. I have a problem in translating the data sent between client and server. So, for example, my client wants to send a character 'E' to the server, so I convert it to byte and use this code byte[] outStream = System.Text.Encoding.ASCII.GetBytes(message); serverStream.Write(outStream, 0, outStream.Length); Then later on the server side, I received with this code strncpy_s(recvbuf, messageObject.messageBuffer, result); Both recvbuf and messageObject.messageBuffer are arrays of char. However, when I print the received char (in the first index of the array) by using a simple std::cout, it always print "=" instead of whatever character I send from the client. Any idea where the problem is? Thanks in advance
  2. jt.tarigan

    C++: how does strncpy_s work?

    I decided to keep using this one: strncpy_s(dst, 1024,src, 442); I've read somewhere that this is probably the best solution since there is no performance hiccup. I only need to make sure that the source does not exceed the length of the destination. Thanks for the reply
  3. Hi, I'm having trouble to understand the behavior of strncpy_s. So I have char* dst which is later defined as an array of char with the size of 1024 (max possible length). I tried to fill with chars from char* src with the length of 442. So I use strncpy_s like this: strncpy_s(dst, 442,src, 442); It always returns an error (L'Buffer is too small). I don't get it since the destination length and source is the same, and dst is actually larger than src. But when I changed the code to this strncpy_s(dst, 1024,src, 442); the code runs without any error. Of course, I can simply put the maximum number (1024) on the destination length, but I wonder how it actually works. Can anyone help me with this? Thank you
  4. jt.tarigan

    Reading from network stream (C#)

    Thanks for the replies. I think I have a rough idea of how to solve this problem. In short, there is no way to know the length of the byte stream received. What I can do is to modify my protocol so the first thing I put in the data is the length of the data. When the message is received, I should check the length first before going through the data. Is that correct? I'm using Unity + Visual Studio. I am debugging with Unity's built-in console, it does not help very much in showing errors. Sometimes, it just stopped without showing anything.
  5. Hi, I am having a problem reading data from a network. Here is the code of the thread that listening from a thread and saving the content as string. private void ReadData() { string lMessageInString; print("Reading data"); byte[] lInStream = new byte[1024]; char[] lCharStream = new char[1024]; serverStream = clientSocket.GetStream(); while (true) { print("While True"); serverStream.Read(lInStream, 0, lInStream.Length); for (int i = 0; i < lInStream.Length; i++) { lCharStream[i] = (char)(((int)lInStream[i])); } lMessageInString = new string(lCharStream); print("The message length: " + lMessageInString.Length); ProcessMessage(lMessageInString); print(lMessageInString); } } The code seems to work but I have a problem trying to optimize the code. THe size of the string (which is derived from the array of char) is 1024 instead of the size of the character sent by the network. Using method serverStream.Length seems to fail the program. How can I limit the string length to match the size of the received characters from the stream? ie. if there are only 10 characters (bytes), the string will have 10 characters instead of the maximum 1024. It seems redundant to process the whole array when the stream only sent 10 characters. Thank you in advance
  6. jt.tarigan

    Link for Graphics Research Papers

    wow thats a lot, thx   anw, i decided to go for procedural on terrain generator. any specific paper for me? any idea on title that might be good for me?   thanks
  7. Hi,    Im new here. Sorry in advance if there's a problem with my very first post ;)   I'm currently looking for a link to find research papers in Computer Graphic (or anything related to it). AI and mobile are also welcome. Anyone can give me a good link to them? I've tried google but most of the times, it does not give me a good result or a link to a paid web. I don't mind paying for a membership, but hoping just to pay for a single web site. Which one is the best?   Im trying to make a research paper in procedural generation. anyone can give me a link to these kind of papers?    Thanks  
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!