| |

VerySource

 Forgot password?
 Register
Search
View: 981|Reply: 6

How socket sends structure data :::

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-18 21:20:01
| Show all posts |Read mode
How socket sends structure data :::

If I define a structure, how can I send it through a socket ????

  TChargeSet = record
    Name: string; {charging method}
    FreeTime: Integer; {free time, minutes}
    SetTime: Integer; {time unit, minute}
    SetCost: Single; {charge amount, yuan}
    HintStr: string; {Tips for charging}
  end;

  TChargeMsg = record
    IpAddress: string;
    CardNo: string;
    Flag: Integer; {status word}
    OpenTime: TDatetime;
    ChargeTime: TDatetime; {Next charge time}
    UseTime: Integer;
    ChargeSet: TChargeSet; {Charging Rules}
    Cost: Single; {Total Charge}
    Blance: Single; {balance}
    NewOpen: Integer;
    Memos: string;
  end;

var
  TChargeMsg: TChargeMsg;
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-31 17:27:02
| Show all posts
SOCKET sends a piece of data in memory. As for what this data is, you determine it yourself.
For the object in the structure, because only a pointer is saved, it can be sent after it is persisted.

STRING is also an object in DELPHI. So you can't use it directly, you must define the format of a character array.
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-2-1 03:36:01
| Show all posts
Thank悲歌人生

 Can you give some code, examples!
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-14 01:15:01
| Show all posts
tool = packed record
        mindex: array [0..3] of char; //Ë ÷Òý ± àºÅ
        mcname: array [0..6] of char; //Ãû³Æ
        mcpic: array [0..50] of char; //ĬÈÏͼƬµØÖ ·
        cx: array [0..3] of char; //¼Ç¼ĬÈÏ¿ í¶È
        cy: array [0..3] of char; //¼Ç¼ĬÈϸ߶È
        cmemo: array [0..3] of char; //¼Ç¼ ±¸ ×¢
    end;

Defined as
 In sengbuf
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-4-12 10:00:01
| Show all posts
tool = packed record
        mindex: array [0..3] of char;
        mcname: array [0..6] of char;
end;

Upstairs can be defined like this.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-17 12:15:01
| Show all posts
buf <-structobj
size->sizeof(struct)
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-17 15:45:01
| Show all posts
sdk:
send or sendto
buf fills the structure pointer and len structure size.

TCustomWinSocket::SendBuf
buf fill structure pointer Count fill structure size
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list